Esempio n. 1
0
        public void finds_the_rules()
        {
            var r1 = new StubRule();
            var r2 = new StubRule();
            var r3 = new ClassFieldValidationRules();

            var src = new ConfiguredValidationSource(new IValidationRule[] {r1, r2, r3});
            var step = ValidationStep.FromSource(typeof (object), src);

            step.FindRules<StubRule>().ShouldHaveTheSameElementsAs(r1, r2);
        }
Esempio n. 2
0
        public void finds_the_rules()
        {
            var r1 = new StubRule();
            var r2 = new StubRule();
            var r3 = new ClassFieldValidationRules();

            var src  = new ConfiguredValidationSource(new IValidationRule[] { r1, r2, r3 });
            var step = ValidationStep.FromSource(typeof(object), src);

            step.FindRules <StubRule>().ShouldHaveTheSameElementsAs(r1, r2);
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        public void finds_the_rules_from_all_steps()
        {
            var r1 = new StubRule();
            var r2 = new StubRule();
            var r3 = new ClassFieldValidationRules();
            var r4 = new ClassFieldValidationRules();

            var src1 = new ConfiguredValidationSource(new IValidationRule[] { r1, r3 });
            var src2 = new ConfiguredValidationSource(new IValidationRule[] { r2, r4 });

            var step1 = ValidationStep.FromSource(typeof(object), src1);
            var step2 = ValidationStep.FromSource(typeof(object), src2);

            var plan = new ValidationPlan(typeof (object), new[] {step1, step2});
            plan.FindRules<StubRule>().ShouldHaveTheSameElementsAs(r1, r2);
        }
Esempio n. 5
0
        public void finds_the_rules_from_all_steps()
        {
            var r1 = new StubRule();
            var r2 = new StubRule();
            var r3 = new ClassFieldValidationRules();
            var r4 = new ClassFieldValidationRules();

            var src1 = new ConfiguredValidationSource(new IValidationRule[] { r1, r3 });
            var src2 = new ConfiguredValidationSource(new IValidationRule[] { r2, r4 });

            var step1 = ValidationStep.FromSource(typeof(object), src1);
            var step2 = ValidationStep.FromSource(typeof(object), src2);

            var plan = new ValidationPlan(typeof(object), new[] { step1, step2 });

            plan.FindRules <StubRule>().ShouldHaveTheSameElementsAs(r1, r2);
        }
Esempio n. 6
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 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. 8
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>();
            });
        }