private FormRequest requestFor <T>() where T : class, new()
        {
            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(theGraph));
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest()));

            theRequest      = new InMemoryFubuRequest();
            theNotification = Notification.Valid();
            theRequest.Set(theNotification);

            services.Add(theRequest);

            var request = new FormRequest(new ChainSearch {
                Type = typeof(T)
            }, new T());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            theContinuation = AjaxContinuation.Successful();
            theContinuation.ShouldRefresh = true;

            var resolver = MockRepository.GenerateStub <IAjaxContinuationResolver>();

            resolver.Stub(x => x.Resolve(theNotification)).Return(theContinuation);

            services.Add(resolver);

            return(request);
        }
예제 #2
0
        private FormRequest createRequest()
        {
            var rules     = new AccessorRules();
            var overrides = new ValidationOptionsTargetOverrides().As <IAccessorRulesRegistration>();

            overrides.AddRules(rules);

            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(theGraph));
            services.Add(rules);
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest()));
            services.Add <ITypeResolver>(new TypeResolver());
            services.Add <ITypeDescriptorCache>(new TypeDescriptorCache());

            var graph = ValidationGraph.BasicGraph();

            graph.Fields.FindWith(new AccessorRulesFieldSource(rules));

            services.Add(graph);

            var request = new FormRequest(new ChainSearch {
                Type = typeof(ValidationOptionsTarget)
            }, new ValidationOptionsTarget());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            return(request);
        }
예제 #3
0
        public void SetUp()
        {
            theRequest = new FormRequest(new ChainSearch {
                Type = typeof(object)
            }, new object());
            var theForm = new FormTag("test");

            theRequest.ReplaceTag(theForm);
        }
예제 #4
0
        private FormRequest requestFor <T>() where T : class, new()
        {
            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(new TypeResolver(), theGraph));
            services.Add(theValidationGraph);
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new StandInCurrentHttpRequest()));

            var request = new FormRequest(new ChainSearch {
                Type = typeof(T)
            }, new T());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            return(request);
        }
예제 #5
0
        private FormRequest requestFor <T>() where T : class, new()
        {
            var services = new InMemoryServiceLocator();

            services.Add <IChainResolver>(new ChainResolutionCache(theGraph));
            services.Add <IChainUrlResolver>(new ChainUrlResolver(new OwinHttpRequest()));
            services.Add <ITypeResolver>(new TypeResolver());
            services.Add(new AccessorRules());
            services.Add <ITypeDescriptorCache>(new TypeDescriptorCache());
            services.Add(theSettings);

            var request = new FormRequest(new ChainSearch {
                Type = typeof(T)
            }, new T());

            request.Attach(services);
            request.ReplaceTag(new FormTag("test"));

            return(request);
        }
        protected override void beforeEach()
        {
            theGraph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeType <ValidationSummaryTargetEndpoint>());
            Services.Inject <IChainResolver>(new ChainResolutionCache(theGraph));


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

            ValidationPolicy.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.ToCompletionTask());
        }