public void GetNameOverloadTest2() { var model = new TestModel(); var actual = PropertyChanged.GetName( () => PropertyChanged ); Assert.AreEqual( "PropertyChanged", actual ); }
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)); } }
public void GetNameOverloadTest1() { var model = new TestModel(); var actual = model.Name.GetName( () => model.Name ); Assert.AreEqual( "Name", actual ); }
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()); }
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)); }
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); }
public TestModel EndTest(ITestEvaluator evaluator) { _currentTest.Assessments.Add(evaluator.Name, evaluator.Assess(_currentTest)); TestModel test = _currentTest; _currentTest = null; return test; }
public void ReturnsRightOwnerWhenUsingAdditionalParentWithIntProperty() { var testModel = new TestModel(); var owner = ExpressionHelper.GetOwner(() => testModel.IntProperty); Assert.IsTrue(ReferenceEquals(testModel, owner)); }
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); } }
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()); } } }
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)); } }
public void GetNameTest() { var model = new TestModel(); var actual = model.GetName( x => x.Age ); Assert.AreEqual( "Age", actual ); }
public void GetNameChainOverload1TestCase1() { var model = new TestModel(); var actual = model.GetNameChain( x => model.Age ); Assert.AreEqual( "Age", actual ); }
public void GetNameChainOverload1TestCase2() { var model = new TestModel(); var actual = model.GetNameChain( () => model.SubModel.Foo ); Assert.AreEqual( "SubModel.Foo", actual ); }
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)); }
public void SetUp() { _model = new TestModel(); _router = new StubRouter<TestModel>(_model); _stringSubject = new StubSubject<string>(); _intSubject = new StubSubject<int>(); _decimalSubject = new StubSubject<decimal>(); }
public void ValidateValidObjectReturnsEmptyListValidationResult() { var sut = new TestModel() { Name = "Name", SubModel = new SubModel { Property1 = "1" } }; var validationResults = sut.Validate(); Assert.Empty(validationResults); }
public void GetNameChainOverload1TestCase4() { var model = new TestModel(); Expression<Func<Object>> expression1 = () => model.SubModel.Foo; var actual = model.GetNameChain( expression1 ); Assert.AreEqual( "SubModel.Foo", actual ); }
public void BuilderModelLoadAndChangeState() { // Создадим и изменим. TestModel model = new TestModel(); ((TestProduct)model.MainItem).Id = "777"; Assert.AreEqual(ModelState.New, model.State); Assert.IsNull(model.LoadedFileName); }
public void RowSelectedForObject () { var model = new TestModel (); string result = null; model.ItemSelected += (sender, arg) => result = (string)arg.Data; model.RowSelected ("Foobar"); Assert.AreEqual ("Foobar", result); }
public ActionResult TestUiDateTimeModelAsParameter() { var model = new TestModel { ModelOne = new UiDateTimeModel("US Eastern Standard Time"), ModelTwo = new UiDateTimeModel("Pacific Standard Time") }; return View(model); }
public void AssertValidOnInvalidObjectThrowsArgumentException() { var sut = new TestModel(); var ex = Assert.Throws<ArgumentException>(() => sut.AssertValid("sut")); Assert.Equal("sut", ex.ParamName); Assert.Contains("Name: Value is required.", ex.Message); }
public void Add_ShouldAddItem() { var fakeDbSet = Aef.FakeDbSet(new List<TestModel> { new TestModel(), new TestModel() }); var newModel = new TestModel(); fakeDbSet.Add(newModel); CollectionAssert.Contains(fakeDbSet.ToList(), newModel); }
public ActionResult Add(TestModel Model) { if (ModelState.IsValid) { db.test.Add(Model); db.SaveChanges(); } return View(); }
public void BeginTest(Test test) { if (_currentTest != null) throw new InvalidOperationException("Finish the current test before starting a new test"); _currentTest = new TestModel(test, _logger); RaisePropertyChanged("CurrentTest"); }
private void AssertEqual(TestModel[] expected, object[][] actual) { for (int i = 0; i < expected.Count(); i++) { Assert.Equal(expected[i].Id, actual[i][0]); Assert.Equal(expected[i].Name, actual[i][1]); Assert.Equal(expected[i].Description, actual[i][2]); } }
public void CanCloneMarshalByRefModel() { var model = new TestModel(); model.AddCustomer("Zippy"); var clone = new BinaryFormatter().Clone(model); model.AddCustomer("asfafse"); Assert.IsTrue(clone.Customers.Count() == 1); }
public string Post(TestModel model) { if (!ModelState.IsValid) { return "Failure, but still hit controller"; } return "OK"; }
public void OneContextOneNode() { string context = "Context1"; TestModel model = new TestModel(); INode node = model.CreateAddNode(10, context, new Size(100, 50)); TimelineLayoutManager layout = new TimelineLayoutManager(model); layout.Update(); Assert.That(node.Position, Is.EqualTo(new Point(layout.XMargin, layout.YMargin))); }
public void TestMakingUrlWithIgnore() { var model = new TestModel { A = "TestA", B = "TestB" }; var urlString = UrlUtils.ToUrlParamString(model, "a"); Assert.AreEqual("b=TestB", urlString); }
public void DateParser(TestModel testSpec) { ExtractorInitialize(Extractors); ParserInitialize(Parsers); TestDateTimeParser(testSpec); }
public void Delete(TestModel test) { _context.TestModels.Remove(test); _context.SaveChanges(); }
public void OrdinalModel(TestModel testSpec) { TestNumber(testSpec); }
public void AgeModel(TestModel testSpec) { TestNumberWithUnit(testSpec); }
public void DateExtractor(TestModel testSpec) { ExtractorInitialize(Extractors); TestDateTimeExtractor(testSpec); }
public string UpdateTestData(TestModel model) { throw new NotImplementedException(); }
/// <summary> /// 增加tb_test数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool TestAdd(TestModel model) { return(baseDal.DapperInsert <TestModel>(model)); }
public void DimensionModel(TestModel testSpec) { TestNumberWithUnit(testSpec); }
public void ComplexObject_Test() { var initial = new TestModel { Id = Guid.Parse("aa7daced-c9fa-489b-9bc1-540b21d277a1"), Attributes = JsonDocument.Parse("[{\"test\":\"test123\"},{\"test\":\"test32132\"},{\"test1\":\"test321\"},{\"test\":[1,2,3]},{\"test\":[1,2,3]}]").RootElement, Name = "Test", Numbers = new[] { 1, 2, 3 }, Strings = new[] { "test1", "test2" }, InnerObjects = new List <TestModel> { new TestModel { Id = Guid.Parse("b2cab2a0-ec23-405a-a5a8-975448a10334"), Name = "TestNameInner1", Numbers = new[] { 3, 2, 1 }, Strings = new[] { "Test3", "test4" } } } }; var expected = new TestModel { Id = Guid.Parse("4801bd62-a8ec-4ef2-ae3c-52b9f541625f"), Attributes = JsonDocument.Parse("[{\"test1\":\"test123\"},{\"test\":\"test32132\"},{\"test1\":\"test321\"},{\"test\":[1,1,3]}]").RootElement, Name = "Test4", Numbers = new[] { 1, 2, 3, 4 }, Strings = new[] { "test2", "test2" }, InnerObjects = new List <TestModel> { new TestModel { Id = Guid.Parse("bed584b0-7ccc-4336-adba-d0d7f7c3c3f2"), Name = "TestNameInner1", Numbers = new[] { 1, 2, 1 }, Strings = new[] { "Test3", "test4", "test5" } } } }; var patchExpectedStr = "[{\"op\":\"replace\",\"path\":\"/Id\",\"value\":\"4801bd62-a8ec-4ef2-ae3c-52b9f541625f\"}," + "{\"op\":\"replace\",\"path\":\"/Name\",\"value\":\"Test4\"}," + "{\"op\":\"add\",\"path\":\"/Numbers/3\",\"value\":4}," + "{\"op\":\"replace\",\"path\":\"/Strings/0\",\"value\":\"test2\"}," + "{\"op\":\"replace\",\"path\":\"/InnerObjects/0/Id\",\"value\":\"bed584b0-7ccc-4336-adba-d0d7f7c3c3f2\"}," + "{\"op\":\"replace\",\"path\":\"/InnerObjects/0/Numbers/0\",\"value\":1}," + "{\"op\":\"add\",\"path\":\"/InnerObjects/0/Strings/2\",\"value\":\"test5\"}," + "{\"op\":\"remove\",\"path\":\"/Attributes/0/test\"}," + "{\"op\":\"add\",\"path\":\"/Attributes/0/test1\",\"value\":\"test123\"}," + "{\"op\":\"replace\",\"path\":\"/Attributes/3/test/1\",\"value\":1}," + "{\"op\":\"remove\",\"path\":\"/Attributes/4\"}]"; var patchExpected = JsonSerializer.Deserialize <JsonPatch>(patchExpectedStr); var patchBackExpectedStr = "[{\"op\":\"replace\",\"path\":\"/Id\",\"value\":\"aa7daced-c9fa-489b-9bc1-540b21d277a1\"}," + "{\"op\":\"replace\",\"path\":\"/Name\",\"value\":\"Test\"}," + "{\"op\":\"remove\",\"path\":\"/Numbers/3\"}," + "{\"op\":\"replace\",\"path\":\"/Strings/0\",\"value\":\"test1\"}," + "{\"op\":\"replace\",\"path\":\"/InnerObjects/0/Id\",\"value\":\"b2cab2a0-ec23-405a-a5a8-975448a10334\"}," + "{\"op\":\"replace\",\"path\":\"/InnerObjects/0/Numbers/0\",\"value\":3}," + "{\"op\":\"remove\",\"path\":\"/InnerObjects/0/Strings/2\"}," + "{\"op\":\"remove\",\"path\":\"/Attributes/0/test1\"}," + "{\"op\":\"add\",\"path\":\"/Attributes/0/test\",\"value\":\"test123\"}," + "{\"op\":\"replace\",\"path\":\"/Attributes/3/test/1\",\"value\":2},{\"op\":\"add\",\"path\":\"/Attributes/4\",\"value\":{\"test\":[1,2,3]}}]"; var patchBackExpected = JsonSerializer.Deserialize <JsonPatch>(patchBackExpectedStr); var patch = initial.CreatePatch(expected, new JsonSerializerOptions { IgnoreNullValues = true }); var patchBack = expected.CreatePatch(initial, new JsonSerializerOptions { IgnoreNullValues = true }); Assert.AreEqual(patchExpected, patch); Assert.AreEqual(patchBackExpected, patchBack); }
public ActionResult Upload(TestModel model, IEnumerable <HttpPostedFileBase> files) { return(Json(new { files = files.ToList().Select(x => x.FileName), model = model })); }
public void TemperatureModel(TestModel testSpec) { TestNumberWithUnit(testSpec); }
public void PercentModel(TestModel testSpec) { TestNumber(testSpec); }
public void NumberModel(TestModel testSpec) { TestNumber(testSpec); }
public void CurrencyModel(TestModel testSpec) { TestCurrency(testSpec); }
public void BooleanModel(TestModel testSpec) { TestChoice(testSpec); }
public void CurrencyModel(TestModel testSpec) { TestNumberWithUnit(testSpec); }
public void TestPropertyReturnsFoo() { var model = new TestModel(); Assert.Equal("foo", model.TestProperty); }
public void AllowObservableAsPropertyAttributeOnAccessor() { var model = new TestModel("foo"); Assert.Equal("foo", model.MyProperty); }
/// <summary> /// 更新tb_test数据 单个更新数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool TestUpdate(TestModel model) { return(baseDal.DapperUpDate <TestModel>(model)); }
public Task <TestModel> Test1Async(TestModel request) { return(Task.FromResult(request)); }
public void DateTimeModelExperimentalMode(TestModel testSpec) { TestDateTimeAlt(testSpec); }
public IActionResult ComplexTypeModelWithCancellationToken(TestModel model, CancellationToken cancellationToken) => null;
public void DateTimeModel(TestModel testSpec) { TestDateTime(testSpec); }
public IActionResult ComplexTypeModel(TestModel model) => null;
public async Task <IActionResult> DeleteConfirmed(TestModel test) { _testService.Delete(test); return(RedirectToAction(nameof(Index))); }
public IActionResult InferredAndSpecified(TestModel a, [FromBody] int b) => null;
public IActionResult MultipleInferred(TestModel a, Car b) => null;
public IActionResult SomeAction([FromQuery] TestModel test) => null;
protected override void Check() { var c = new C(); Probability probabilityOfFinal1; var final1Formula = new UnaryFormula(c.InA(), UnaryOperator.Finally); var markovChainGenerator = new SafetySharpMarkovChainFromExecutableModelGenerator(TestModel.InitializeModel(c)); markovChainGenerator.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small; markovChainGenerator.Configuration.WriteGraphvizModels = true; markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.DefaultTraceOutput = Output.TextWriterAdapter(); markovChainGenerator.Configuration.LtmcModelChecker = (ISSE.SafetyChecking.LtmcModelChecker)Arguments[0]; markovChainGenerator.AddFormulaToCheck(final1Formula); var ltmc = markovChainGenerator.GenerateLabeledMarkovChain(); var modelChecker = new ConfigurationDependentLtmcModelChecker(markovChainGenerator.Configuration, ltmc, Output.TextWriterAdapter()); using (modelChecker) { probabilityOfFinal1 = modelChecker.CalculateProbability(final1Formula); } probabilityOfFinal1.Between(0.3, 0.4).ShouldBe(true); }
public TestViewModel(bool language, TestModel tm) { this.enLanguage = language; this.tm = tm; Load_Method(); }