Esempio n. 1
0
        public void adds_validation_action_filter_for_lofi_endpoints()
        {
            var call = ActionCall.For <SampleInputModel>(x => x.Test(null));

            var chain = new BehaviorChain();

            chain.AddToEnd(call);

            ValidationConvention.ApplyValidation(call, new ValidationSettings());

            var nodes = chain.ToArray();
            var node  = nodes[0].As <IHaveValidation>();

            node.As <ActionFilter>().HandlerType.ShouldEqual(typeof(ValidationActionFilter <string>));
        }
Esempio n. 2
0
        public void adds_ajax_validation_action_filter_for_ajax_endpoints()
        {
            var call = ActionCall.For <SampleAjaxModel>(x => x.post_model(null));

            var chain = new BehaviorChain();

            chain.AddToEnd(call);

            ValidationConvention.ApplyValidation(call, new ValidationSettings());

            var nodes = chain.ToArray();
            var node  = nodes[0].As <IHaveValidation>();

            node.ShouldBeOfType <AjaxValidationNode>();
        }
Esempio n. 3
0
        public void no_modifications_from_the_settings()
        {
            var call = ActionCall.For <SampleInputModel>(x => x.Test(null));

            var chain = new BehaviorChain();

            chain.AddToEnd(call);

            var settings = new ValidationSettings();

            settings.ForInputType <int>(x =>
            {
                x.Clear();
                x.RegisterStrategy(RenderingStrategies.Inline);
            });

            ValidationConvention.ApplyValidation(call, settings);

            chain.ValidationNode().ShouldHaveTheSameElementsAs(RenderingStrategies.Summary, RenderingStrategies.Highlight);
        }
Esempio n. 4
0
        protected override void beforeEach()
        {
            theGraph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeType <ValidationSummaryTargetEndpoint>());
            Services.Inject <IChainResolver>(new ChainResolutionCache(new TypeResolver(), theGraph));


            theRequest = new FormRequest(new ChainSearch {
                Type = typeof(ValidationSummaryTarget)
            },
                                         new ValidationSummaryTarget());
            theRequest.Attach(new StructureMapServiceLocator(Services.Container));

            ValidationConvention.ApplyValidation(theRequest.Chain.FirstCall(), new ValidationSettings());
            theRequest.Chain.ValidationNode().Clear();
            theRequest.Chain.ValidationNode().RegisterStrategy(RenderingStrategies.Summary);

            var theForm = new FormTag("test");

            theForm.Append(new HtmlTag("input").Attr("type", "text").Attr("name", "Name"));

            theRequest.ReplaceTag(theForm);

            MockFor <IPartialInvoker>().Stub(x => x.Invoke <ValidationSummary>()).Return(theValidationSummary);
        }