Esempio n. 1
0
        public void no_match_when_token_is_null()
        {
            var theRule = new RequiredFieldRule();

            theRule.Token = null;
            theStrategy.Matches(theRule).ShouldBeFalse();
        }
Esempio n. 2
0
        public void SetUp()
        {
            theRule = new RequiredFieldRule();
            f1      = MockRepository.GenerateStub <IRemoteRuleFilter>();
            f2      = MockRepository.GenerateStub <IRemoteRuleFilter>();

            theQuery = new RemoteRuleQuery(new[] { f1, f2 });
        }
        public void SetUp()
        {
            theRule = new RequiredFieldRule();
            f1 = MockRepository.GenerateStub<IRemoteRuleFilter>();
            f2 = MockRepository.GenerateStub<IRemoteRuleFilter>();

            theQuery = new RemoteRuleQuery(new[] { f1, f2 });
        }
        public void finds_the_rule_by_the_hash()
        {
            var a1 = ReflectionHelper.GetAccessor <RuleGraphModel>(x => x.FirstName);
            var r1 = new RequiredFieldRule();

            theGraph.RegisterRule(a1, r1);

            var remote = RemoteFieldRule.For(a1, r1);

            theGraph.RuleFor(remote.ToHash()).ShouldEqual(remote);
        }
        public void finds_the_rule_by_the_hash()
        {
            var a1 = ReflectionHelper.GetAccessor<RuleGraphModel>(x => x.FirstName);
            var r1 = new RequiredFieldRule();

            theGraph.RegisterRule(a1, r1);

            var remote = RemoteFieldRule.For(a1, r1);

            theGraph.RuleFor(remote.ToHash()).ShouldBe(remote);
        }
        public void SetUp()
        {
            theRule             = new RequiredFieldRule();
            theElementRequest   = ElementRequest.For <FieldValidationModifierTarget>(x => x.Name);
            theMatchingStrategy = MockRepository.GenerateStub <IValidationAnnotationStrategy>();
            theOtherStrategy    = MockRepository.GenerateStub <IValidationAnnotationStrategy>();

            theMatchingStrategy.Stub(x => x.Matches(theRule)).Return(true);
            theOtherStrategy.Stub(x => x.Matches(theRule)).Return(false);

            theModifier = new FieldValidationModifier(new[] { theMatchingStrategy, theOtherStrategy });
            theModifier.ModifyFor(theRule, theElementRequest);
        }
        public void registers_rules()
        {
            var a1 = ReflectionHelper.GetAccessor <RuleGraphModel>(x => x.FirstName);
            var a2 = ReflectionHelper.GetAccessor <RuleGraphModel>(x => x.LastName);

            var r1 = new RequiredFieldRule();
            var r2 = new MinimumLengthRule(5);

            theGraph.RegisterRule(a1, r1);
            theGraph.RegisterRule(a1, r2);

            theGraph.RegisterRule(a2, r1);

            theGraph.RulesFor(a1).ShouldHaveTheSameElementsAs(RemoteFieldRule.For(a1, r1), RemoteFieldRule.For(a1, r2));
            theGraph.RulesFor(a2).ShouldHaveTheSameElementsAs(RemoteFieldRule.For(a2, r1));
        }
        public void registers_rules()
        {
            var a1 = ReflectionHelper.GetAccessor<RuleGraphModel>(x => x.FirstName);
            var a2 = ReflectionHelper.GetAccessor<RuleGraphModel>(x => x.LastName);

            var r1 = new RequiredFieldRule();
            var r2 = new MinimumLengthRule(5);

            theGraph.RegisterRule(a1, r1);
            theGraph.RegisterRule(a1, r2);

            theGraph.RegisterRule(a2, r1);

            theGraph.RulesFor(a1).ShouldHaveTheSameElementsAs(RemoteFieldRule.For(a1, r1), RemoteFieldRule.For(a1, r2));
            theGraph.RulesFor(a2).ShouldHaveTheSameElementsAs(RemoteFieldRule.For(a2, r1));
        }
Esempio n. 9
0
        public void matches_when_token_is_not_null()
        {
            var theRule = new RequiredFieldRule();

            theStrategy.Matches(theRule).ShouldBeTrue();
        }
Esempio n. 10
0
 public void BeforeEach()
 {
     theRule   = new RequiredFieldRule();
     theTarget = new AddressModel();
 }
 public void no_match_when_token_is_null()
 {
     var theRule = new RequiredFieldRule();
     theRule.Token = null;
     theStrategy.Matches(theRule).ShouldBeFalse();
 }
 public void matches_when_token_is_not_null()
 {
     var theRule = new RequiredFieldRule();
     theStrategy.Matches(theRule).ShouldBeTrue();
 }