Esempio n. 1
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);
        }
Esempio n. 2
0
 public ScenarioDefinition()
 {
     Tag      = new HtmlTag("input");
     Services = new InMemoryServiceLocator();
     Modifier = new T();
     Services.Add(ValidationGraph.BasicGraph());
 }
        public void SetUp()
        {
            theSelfValidatingSource = new SelfValidatingClassRuleSource();

            theFieldRegistry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            theGraph = new ValidationGraph(theFieldRegistry, new IValidationSource[0]);
        }
        public void SetUp()
        {
            theSelfValidatingSource = new SelfValidatingClassRuleSource();

            theFieldRegistry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            theGraph         = new ValidationGraph(theFieldRegistry, new IValidationSource[0]);
        }
 public void Configure(ValidationGraph graph)
 {
     foreach (var chain in graph.Chains.ToList())
     {
         CopyCallsForChain(graph, chain);
     }
 }
 public void Configure(ValidationGraph graph)
 {
     graph
         .Chains
         .Each(chain => chain
                            .ModelType
                            .EachProperty(p => p.GetValidationAttributes().Each(attribute => chain.AddCall(new ValidationCall(attribute.RuleType,new Accessor(chain.ModelType, p))))));
 }
 public RemoteRuleGraphActivator(ValidationGraph graph, RemoteRuleGraph remoteGraph, BehaviorGraph behaviorGraph, IRemoteRuleQuery remotes, ITypeDescriptorCache properties)
 {
     _graph = graph;
     _remoteGraph = remoteGraph;
     _behaviorGraph = behaviorGraph;
     _remotes = remotes;
     _properties = properties;
 }
Esempio n. 8
0
 public RemoteRuleGraphActivator(ValidationGraph graph, RemoteRuleGraph remoteGraph, BehaviorGraph behaviorGraph, IRemoteRuleQuery remotes, ITypeDescriptorCache properties)
 {
     _graph         = graph;
     _remoteGraph   = remoteGraph;
     _behaviorGraph = behaviorGraph;
     _remotes       = remotes;
     _properties    = properties;
 }
        private IEnumerable <IFieldValidationRule> rulesFor(Expression <Func <ClassValidationRulesTarget, object> > expression)
        {
            var registry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            var graph    = ValidationGraph.For(registry);

            graph.Import(theRules);

            return(registry.RulesFor(typeof(ClassValidationRulesTarget)).RulesFor(expression.ToAccessor()));
        }
Esempio n. 10
0
 public void Configure(ValidationGraph graph)
 {
     graph
         .Chains
         .Each(chain => chain
                            .ModelType
                            .PropertiesWhere(_predicate)
                            .Each(p => _rulesToAdd.Each(
                                ruleType =>
                                chain.AddCall(new ValidationCall(ruleType,
                                                                 new Accessor(chain.ModelType, p))))));
 }
Esempio n. 11
0
        public HelloWorldHtmlConventions(ValidationGraph graph)
        {
            _graph = graph;

            Editors
                .If(a => a.Accessor.FieldName.Contains("Password"))
                .Modify(t => t.Attr("type", "password"));

            Editors
                .Always
                .Modify(ModifyWithValidationGraph);
        }
Esempio n. 12
0
        protected override void beforeEach()
        {
            theGraph = ValidationGraph.BasicGraph();
            Services.Inject(theGraph);

            theTypes = new TypePool();
            theTypes.AddType <RegistrationTargetRules>();

            Services.PartialMockTheClassUnderTest();
            ClassUnderTest.Stub(x => x.Types()).Return(theTypes);

            ClassUnderTest.Activate(new IPackageInfo[0], new PackageLog());
        }
Esempio n. 13
0
        public void SetUp()
        {
            theRequest       = ElementRequest.For <FieldValidationModifierTarget>(x => x.Name);
            theModifier      = new FieldValidationElementModifier();
            theFieldModifier = MockRepository.GenerateStub <IFieldValidationModifier>();

            theRequest.ReplaceTag(new HtmlTag("input"));

            theServices = new InMemoryServiceLocator();
            theServices.Add(ValidationGraph.BasicGraph());
            theServices.Add(theFieldModifier);

            theRequest.Attach(theServices);
        }
Esempio n. 14
0
        protected override void beforeEach()
        {
            theModel         = new SimpleModel();
            theRecordingRule = new RecordingValidationRule();

            var theSource = ConfiguredValidationSource.For(theModel.GetType(), theRecordingRule);

            theGraph = ValidationGraph.For(theSource);

            Services.Inject <ITypeResolver>(new TypeResolver());
            Services.Inject(theGraph);

            ClassUnderTest.Validate(theModel);

            theContext = theRecordingRule.Context;
        }
        public void SetUp()
        {
            theBehaviorGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.Actions.IncludeType <RemoteRuleGraphEndpoint>();
                r.Features.Validation.Enable(true);
            });

            theValidationGraph = ValidationGraph.BasicGraph();
            theRuleGraph       = new RemoteRuleGraph();
            theQuery           = RemoteRuleQuery.Basic();

            theActivator = new RemoteRuleGraphActivator(theValidationGraph, theRuleGraph, theBehaviorGraph, theQuery, new TypeDescriptorCache());

            theActivator.Activate(new ActivationLog(), new PerfTimer());
        }
        public void SetUp()
        {
            theBehaviorGraph = BehaviorGraph.BuildFrom(r =>
            {
                r.Actions.IncludeType <RemoteRuleGraphEndpoint>();
                r.Import <FubuMvcValidation>();
            });

            theValidationGraph = ValidationGraph.BasicGraph();
            theRuleGraph       = new RemoteRuleGraph();
            theQuery           = RemoteRuleQuery.Basic();

            theActivator = new RemoteRuleGraphActivator(theValidationGraph, theRuleGraph, theBehaviorGraph, theQuery, new TypeDescriptorCache());

            theActivator.Activate(new IPackageInfo[0], new PackageLog());
        }
        public void SetUp()
        {
            theModel = new ContactModel();
            theType = theModel.GetType();

            r1 = MockRepository.GenerateStub<IValidationRule>();
            r2 = MockRepository.GenerateStub<IValidationRule>();
            r3 = MockRepository.GenerateStub<IValidationRule>();

            theMatchingSource = ConfiguredValidationSource.For(type => type == theType, r1, r2);
            theOtherSource = ConfiguredValidationSource.For(type => type == typeof(int), r3);

            theGraph = ValidationGraph.BasicGraph();
            theGraph.RegisterSource(theMatchingSource);
            theGraph.RegisterSource(theOtherSource);

            theContext = ValidationContext.For(theModel);

            thePlan = ValidationPlan.For(theType, theGraph);
        }
Esempio n. 18
0
        public void SetUp()
        {
            theModel = new ContactModel();
            theType  = theModel.GetType();

            r1 = MockRepository.GenerateStub <IValidationRule>();
            r2 = MockRepository.GenerateStub <IValidationRule>();
            r3 = MockRepository.GenerateStub <IValidationRule>();

            theMatchingSource = ConfiguredValidationSource.For(type => type == theType, r1, r2);
            theOtherSource    = ConfiguredValidationSource.For(type => type == typeof(int), r3);

            theGraph = ValidationGraph.BasicGraph();
            theGraph.RegisterSource(theMatchingSource);
            theGraph.RegisterSource(theOtherSource);

            theContext = ValidationContext.For(theModel);

            thePlan = ValidationPlan.For(theType, theGraph);
        }
        public static void CopyCallsForChain(ValidationGraph graph, ValidationChain chain)
        {
            var modelType = chain.ModelType.BaseType;
            while(modelType != null && modelType != typeof(Object))
            {
                var properties = modelType.GetPublicProperties();
                foreach (var property in properties)
                {
                    if (!chain.CallsFor(property.Name).Any())
                    {
                        var parentChain = graph.FindChain(modelType).CallsFor(property.Name);
                        foreach (var call in parentChain)
                        {
                            chain.AddCall(call);
                        }
                    }
                }

                modelType = modelType.BaseType;
            }
        }
Esempio n. 20
0
        public void SetUp()
        {
            token1 = StringToken.FromKeyString("TestKeys:Key1", "Token 1");
            token2 = StringToken.FromKeyString("TestKeys:Key2", "Token 2");

            rule1       = FieldEqualityRule.For <LoFiTarget>(x => x.Value1, x => x.Value2);
            rule1.Token = token1;

            rule2       = FieldEqualityRule.For <LoFiTarget>(x => x.Value1, x => x.Value2);
            rule2.Token = token2;

            var source = new ConfiguredValidationSource(new IValidationRule[] { rule1, rule2 });

            theValidationGraph = ValidationGraph.For(source);

            theGraph = BehaviorGraph.BuildFrom(x =>
            {
                x.Actions.IncludeType <FormValidationModeEndpoint>();
                x.Import <FubuMvcValidation>();
            });
        }
 public ValidationRegistrationRunner(ValidationGraph graph, IEnumerable <IValidationRegistration> registrations)
 {
     _graph         = graph;
     _registrations = registrations;
 }
Esempio n. 22
0
 public ValidationDiagnostics(ValidationGraph graph)
 {
     _graph = graph;
 }
Esempio n. 23
0
 public void BuildChains(TypePool types, ValidationGraph graph)
 {
     types
         .TypesMatching(TypeFilters.Matches)
         .Each(type => graph.AddChain(ValidationChain.GenericForModel(type)));
 }
Esempio n. 24
0
 public RuleCompiler(ValidationGraph graph)
 {
     _graph = graph;
 }
		public ValidationRegistrationRunner(ValidationGraph graph, IEnumerable<IValidationRegistration> registrations)
		{
			_graph = graph;
			_registrations = registrations;
		}
        private IEnumerable <IValidationRule> classRules()
        {
            var graph = ValidationGraph.For(theRules);

            return(graph.Sources.SelectMany(source => source.RulesFor(typeof(ClassValidationRulesTarget))));
        }
Esempio n. 27
0
 public void Configure(ValidationGraph graph)
 {
     _action(graph);
 }
 public ValidationRegistrationActivator(ValidationGraph graph)
 {
     _graph = graph;
 }
 public void Register(ValidationGraph graph)
 {
     Configured = graph;
 }
Esempio n. 30
0
 public ValidationProvider(ValidationGraph graph, IRuleCompiler ruleCompiler)
 {
     _graph = graph;
     _ruleCompiler = ruleCompiler;
 }