public void BaseErrorViewModel_GetErrors_Should_Get_SimulatedError() { var vm = new TestErrorViewModel(); vm.SimulateError(); vm.HasErrors.Should().BeTrue(); var e = vm.GetErrors("testProperty"); e.Should().NotBeNull(); e.Should().HaveCount(1); }
public void Test_Vaildator_Error(string FieldValue, bool trg) { var _ServiceHandlerFactory = new TestServiceHandlerFactory(); var _Filter = new TestFilterFactory(); var _testRulesFactory = new TestRulesFactory(); var _common = new CommonInfo(); /* * * (IServiceHandlerFactory ServiceHandlerFactory * , IFilterFactory FilterFactory * , IRule RulesFactor * , ICommonInfo CommonInfo) * */ var testController = new TestController(_ServiceHandlerFactory , _Filter , _testRulesFactory , _common ); SetWebControllerInstance.Initialize(testController); var Model = default(IBaseViewModelRule); Model = new TestViewModel { Name = FieldValue }; if (FieldValue == string.Empty) { Model = new TestErrorViewModel { Name = FieldValue } } ; testController.Validate(Model); var isTrue = testController.ModelState .SelectMany(c => c.Value.Errors) .Any(); Assert.AreNotSame(isTrue.ToString(), trg.ToString(), "Validation Test Failed"); }
public void BaseErrorViewModel_GetErrors_NoErrorsForProperty() { var vm = new TestErrorViewModel(); vm.GetErrors("myProperty").Should().BeNull(); }
public void BaseErrorViewModel_GetErrors_EmptyProperty() { var vm = new TestErrorViewModel(); vm.GetErrors(null).Should().BeNull(); }
public ActionResult HandleError1(TestErrorViewModel data) { return(View()); }