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 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 bool Equals(RequiredFieldRule other)
 {
     return(!ReferenceEquals(null, other));
 }
 public bool Equals(RequiredFieldRule other)
 {
     return !ReferenceEquals(null, other);
 }
Exemple #7
0
 public bool Equals(RequiredFieldRule other)
 {
     return(Token.Equals(other.Token));
 }
 public void BeforeEach()
 {
     theRule = new RequiredFieldRule();
     theTarget = new AddressModel();
 }
 public bool Equals(RequiredFieldRule other)
 {
     return Token.Equals(other.Token);
 }
		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();
		}