Ejemplo n.º 1
0
        public void SetUp()
        {
            theSelfValidatingSource = new SelfValidatingClassRuleSource();

            theFieldRegistry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            theGraph = new ValidationGraph(theFieldRegistry, new IValidationSource[0]);
        }
        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());
        }
Ejemplo n.º 3
0
        public static ValidationPlan For(Type type, ValidationGraph graph)
        {
            var steps = new List <ValidationStep>();

            graph.Sources.Each(source =>
            {
                var rules = source.RulesFor(type);
                if (!rules.Any())
                {
                    return;
                }

                steps.Add(new ValidationStep(type, source.GetType(), rules));
            });

            return(new ValidationPlan(type, steps));
        }
Ejemplo n.º 4
0
 void IValidationRegistration.Register(ValidationGraph graph)
 {
     _rules.Each(r => r.Register(graph.Fields));
     graph.RegisterSource(this);
 }
Ejemplo n.º 5
0
 public void Register(ValidationGraph graph)
 {
     Configured = graph;
 }
Ejemplo n.º 6
0
 public static IValidator BasicValidator()
 {
     return(new Validator(new TypeResolver(), ValidationGraph.BasicGraph(), new InMemoryServiceLocator()));
 }
Ejemplo n.º 7
0
 public Validator(ITypeResolver typeResolver, ValidationGraph graph, IServiceLocator services)
 {
     _typeResolver = typeResolver;
     _graph        = graph;
     _services     = services;
 }
Ejemplo n.º 8
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);
        }