protected DefaultFieldGenerator <TestFieldViewModel, T> Arrange <T>(Expression <Func <TestFieldViewModel, T> > property, params Action <TestFieldViewModel>[] vmSetter)
        {
            H.ViewContext.ViewData.ModelState.AddModelError(H.GetFieldName(property), "asdf");
            var vm = new TestFieldViewModel();

            foreach (var action in vmSetter)
            {
                action(vm);
            }
            H.ViewData.Model = vm;

            return(new DefaultFieldGenerator <TestFieldViewModel, T>(H, property, new DefaultFormTemplate()));
        }
예제 #2
0
        protected DefaultFieldGenerator <TestFieldViewModel, T> Arrange <T>(Expression <Func <TestFieldViewModel, T> > property, params Action <TestFieldViewModel>[] vmSetter)
        {
            H.ViewContext.UnobtrusiveJavaScriptEnabled = true;
            H.ViewContext.ClientValidationEnabled      = true;
            H.ViewContext.ViewData.ModelState.AddModelError(ExpressionHelper.GetExpressionText(property), "asdf");
            var vm = new TestFieldViewModel();

            foreach (var action in vmSetter)
            {
                action(vm);
            }
            H.ViewData.Model = vm;
            H.ViewData.ModelMetadata.Model = vm;

            return(new DefaultFieldGenerator <TestFieldViewModel, T>(H, property, new DefaultFormTemplate()));
        }
        protected DefaultFieldGenerator <TestFieldViewModel, T> Arrange <T>(Expression <Func <TestFieldViewModel, T> > property, params Action <TestFieldViewModel>[] vmSetter)
        {
            H.ViewContext.UnobtrusiveJavaScriptEnabled = true;
            H.ViewContext.ClientValidationEnabled      = true;
            H.ViewContext.ViewData.ModelState.AddModelError(ExpressionHelper.GetExpressionText(property), "asdf");
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredFlagsEnumAttribute), typeof(RequiredAttributeAdapter));
            var vm = new TestFieldViewModel();

            foreach (var action in vmSetter)
            {
                action(vm);
            }
            H.ViewData.Model = vm;
            H.ViewData.ModelMetadata.Model = vm;

            return(new DefaultFieldGenerator <TestFieldViewModel, T>(H, property, new DefaultFormTemplate()));
        }