コード例 #1
0
        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);
        }
コード例 #2
0
            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");
            }
コード例 #3
0
        public void BaseErrorViewModel_GetErrors_NoErrorsForProperty()
        {
            var vm = new TestErrorViewModel();

            vm.GetErrors("myProperty").Should().BeNull();
        }
コード例 #4
0
        public void BaseErrorViewModel_GetErrors_EmptyProperty()
        {
            var vm = new TestErrorViewModel();

            vm.GetErrors(null).Should().BeNull();
        }
コード例 #5
0
ファイル: MBController.cs プロジェクト: coolrare/TABFMVC5
 public ActionResult HandleError1(TestErrorViewModel data)
 {
     return(View());
 }