本文整理汇总了C#中TestModel类的典型用法代码示例。如果您正苦于以下问题:C# TestModel类的具体用法?C# TestModel怎么用?C# TestModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestModel类属于命名空间,在下文中一共展示了TestModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EndTest
public TestModel EndTest(ITestEvaluator evaluator)
{
_currentTest.Assessments.Add(evaluator.Name, evaluator.Assess(_currentTest));
TestModel test = _currentTest;
_currentTest = null;
return test;
}
示例2: ValueHelpersWithErrorsGetValueFromModelState
public void ValueHelpersWithErrorsGetValueFromModelState()
{
// Arrange
var model = new TestModel()
{
StringProperty = "ModelStringPropertyValue",
ObjectProperty = "ModelObjectPropertyValue",
};
var helper = DefaultTemplatesUtilities.GetHtmlHelper<TestModel>(model);
var viewData = helper.ViewData;
viewData["StringProperty"] = "ViewDataValue";
viewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
var modelState = new ModelState();
modelState.Value = new ValueProviderResult(
rawValue: new string[] { "StringPropertyRawValue" },
attemptedValue: "StringPropertyAttemptedValue",
culture: CultureInfo.InvariantCulture);
viewData.ModelState["FieldPrefix.StringProperty"] = modelState;
modelState = new ModelState();
modelState.Value = new ValueProviderResult(
rawValue: new string[] { "ModelRawValue" },
attemptedValue: "ModelAttemptedValue",
culture: CultureInfo.InvariantCulture);
viewData.ModelState["FieldPrefix"] = modelState;
// Act & Assert
Assert.Equal("StringPropertyRawValue", helper.Value("StringProperty"));
Assert.Equal("StringPropertyRawValue", helper.ValueFor(m => m.StringProperty));
Assert.Equal("ModelRawValue", helper.ValueForModel());
}
示例3: GetNameChainOverload1TestCase2
public void GetNameChainOverload1TestCase2()
{
var model = new TestModel();
var actual = model.GetNameChain( () => model.SubModel.Foo );
Assert.AreEqual( "SubModel.Foo", actual );
}
示例4: DocumentStoreWorksWhenAddingItemThenDeletingItAndThenGrabbingNonExistingItemAndStoringNewOne
public void DocumentStoreWorksWhenAddingItemThenDeletingItAndThenGrabbingNonExistingItemAndStoringNewOne()
{
using (var documentStore = new EmbeddableDocumentStore { RunInMemory = true }.Initialize())
{
documentStore.Conventions.AllowQueriesOnId = true;
using (var session = documentStore.OpenSession())
{
var deletedModel = new TestModel { Id = 1 };
session.Store(deletedModel);
session.SaveChanges();
session.Delete(deletedModel);
session.SaveChanges();
TestModel testModelItem = session.Query<TestModel>().SingleOrDefault(t => t.Id == 2) ??
new TestModel { Id = 2 };
Assert.NotNull(testModelItem);
session.Store(testModelItem);
session.SaveChanges();
var list = session.Query<TestModel>()
.Customize(x => x.WaitForNonStaleResults())
.ToList();
Assert.Equal(1, list.Count());
}
}
}
示例5: GetNameOverloadTest1
public void GetNameOverloadTest1()
{
var model = new TestModel();
var actual = model.Name.GetName( () => model.Name );
Assert.AreEqual( "Name", actual );
}
示例6: OneContextTwoNodes
public void OneContextTwoNodes()
{
Gtk.Application.Init ();
string context = "Context1";
TestModel model = new TestModel();
/*INode nodeA = */model.CreateAddNode(10, context, new Size(80, 50));
/*INode nodeB = */model.CreateAddNode(20, context, new Size(100, 40));
TimelineLayoutManager layout = new TimelineLayoutManager(model);
layout.Update();
TestRenderer renderer = new TestRenderer();
TimelineView view = new TimelineView(model, renderer);
Gtk.Widget[] children = view.Children;
Assert.That(children.Length, Is.EqualTo(2));
Assert.That(children[0].Visible, Is.True);
Assert.That(children[1].Visible, Is.True);
int ax = (int) view.ChildGetProperty(children[0], "x").Val;
int ay = (int) view.ChildGetProperty(children[0], "y").Val;
int bx = (int) view.ChildGetProperty(children[1], "x").Val;
int by = (int) view.ChildGetProperty(children[1], "y").Val;
Assert.That(ay, Is.GreaterThan(0));
Assert.That(ay, Is.EqualTo(by));
Assert.That(ax, Is.GreaterThan(0));
Assert.That(bx, Is.GreaterThan(0));
Assert.That(ax, Is.Not.EqualTo(bx));
}
示例7: PersistNewObject
public void PersistNewObject()
{
// Arrange
Bootstrapper.Start();
const string Key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var repository = Bootstrapper.AmbientContainer.GetInstance<Repository<TestModel>>();
var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance<IUnitOfWorkFactory>();
var unitOfWork = unitOfWorkFactory.CreateUnitOfWork();
var testModel = new TestModel(Key);
// Act
using (unitOfWork.Start())
{
repository.Create(testModel);
unitOfWork.Commit();
}
// Assert
using (unitOfWork.Start())
{
var foundModel = repository.Find.OneMatchingExpression(x => x.Key.Equals(Key));
Assert.That(foundModel != null);
}
}
示例8: ReturnsRightOwnerWhenUsingAdditionalParentWithIntProperty
public void ReturnsRightOwnerWhenUsingAdditionalParentWithIntProperty()
{
var testModel = new TestModel();
var owner = ExpressionHelper.GetOwner(() => testModel.IntProperty);
Assert.IsTrue(ReferenceEquals(testModel, owner));
}
示例9: GetNameOverloadTest2
public void GetNameOverloadTest2()
{
var model = new TestModel();
var actual = PropertyChanged.GetName( () => PropertyChanged );
Assert.AreEqual( "PropertyChanged", actual );
}
示例10: ReturnResultsAsDynamicList
public void ReturnResultsAsDynamicList()
{
// Arrange
Bootstrapper.Start();
var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance<IUnitOfWorkFactory>();
var unitOfWork = unitOfWorkFactory.CreateUnitOfWork();
var repository = Bootstrapper.AmbientContainer.GetInstance<Repository<TestModel>>();
const string Key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var testModel = new TestModel(Key);
IList<dynamic> results;
// Act
using (unitOfWork.Start())
{
repository.Create(testModel);
unitOfWork.Commit();
results = unitOfWork.CurrentSession().CreateSQLQuery("SELECT Key FROM TestModel").AsDynamicList();
}
// Assert
Assert.That(results[0].Key.Equals(Key));
}
示例11: ObjectCache
public void ObjectCache()
{
var model = new TestModel() { Id = 101, Name = "TestName" };
this.helper.Set("TestObject",model);
TestModel result = this.helper.Get<TestModel>("TestObject");
Assert.AreEqual(model, result);
}
示例12: ReturnAllMatchingObjects
public void ReturnAllMatchingObjects()
{
// Arrange
Bootstrapper.Start();
var repository = Bootstrapper.AmbientContainer.GetInstance<Repository<TestModel>>();
var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance<IUnitOfWorkFactory>();
var dataCommandProvider = Bootstrapper.AmbientContainer.GetInstance<IDataCommandProvider>();
var unitOfWork = unitOfWorkFactory.CreateUnitOfWork();
var testModel01 = new TestModel("ABCDEF");
var testModel02 = new TestModel("HIJKLM");
var testModel03 = new TestModel("ABCZZZ");
// Act
using (unitOfWork.Start())
{
repository.Create(testModel01);
repository.Create(testModel02);
repository.Create(testModel03);
unitOfWork.Commit();
}
// Assert
using (unitOfWork.Start())
{
var foundModel = repository.Find.AllMatchingQuery(new TestModelsWithTestPropertiesThatStartWithABC(dataCommandProvider));
Assert.That(foundModel.Count().Equals(2));
}
}
示例13: GetNameTest
public void GetNameTest()
{
var model = new TestModel();
var actual = model.GetName( x => x.Age );
Assert.AreEqual( "Age", actual );
}
示例14: GetNameChainOverload1TestCase1
public void GetNameChainOverload1TestCase1()
{
var model = new TestModel();
var actual = model.GetNameChain( x => model.Age );
Assert.AreEqual( "Age", actual );
}
示例15: ReturnAllMatchingObjectsGivenAndSpecification
public void ReturnAllMatchingObjectsGivenAndSpecification()
{
// Arrange
Bootstrapper.Start();
var repository = Bootstrapper.AmbientContainer.GetInstance<Repository<TestModel>>();
var unitOfWorkFactory = Bootstrapper.AmbientContainer.GetInstance<IUnitOfWorkFactory>();
var unitOfWork = unitOfWorkFactory.CreateUnitOfWork();
var testModel01 = new TestModel("ABCDEF");
var testModel02 = new TestModel("HIJKLM");
var testModel03 = new TestModel("ABCXYZ");
// Act
using (unitOfWork.Start())
{
repository.Create(testModel01);
repository.Create(testModel02);
repository.Create(testModel03);
unitOfWork.Commit();
}
// Assert
using (unitOfWork.Start())
{
var foundModel = repository.Find.AllMatchingSpecification(TestModelSpecifications.TestPropertyStartsWithABCAndEndsWithXYZ()).ToList();
Assert.That(foundModel.Count.Equals(1));
}
}