public void Adding_a_validator_should_store_validator()
        {
            var validator = new TestPropertyValidator();

            builder.SetValidator(validator);
            builder.Rule.CurrentValidator.ShouldBeTheSameAs(validator);
        }
        public void Calling_when_should_replace_current_validator_with_predicate_validator()
        {
            var validator = new TestPropertyValidator();
            builder.SetValidator(validator).When(x => true);
            builder.Rule.CurrentValidator.ShouldBe<DelegatingValidator>();

            var predicateValidator = (DelegatingValidator)builder.Rule.CurrentValidator;
            predicateValidator.InnerValidator.ShouldBeTheSameAs(validator);
        }
Exemple #3
0
        public void Calling_when_should_replace_current_validator_with_predicate_validator()
        {
            var validator = new TestPropertyValidator();

            builder.SetValidator(validator).When(x => true);
            builder.Rule.CurrentValidator.ShouldBe <DelegatingValidator>();

            var predicateValidator = (DelegatingValidator)builder.Rule.CurrentValidator;

            predicateValidator.InnerValidator.ShouldBeTheSameAs(validator);
        }
        public void PropertyInContextByPropertyValueTest()
        {
            //property in context by value should ba able to specify a lookup name in case id is not known at compile time
            var testObject = new TestPropertyValidator();

            Assert.IsFalse(testObject.IsInContext(nameof(TestPropertyValidator.DependantOnLookupName)));
            testObject.LookupField = new Lookup("foo", "foo", "Record Name");
            Assert.IsTrue(testObject.IsInContext(nameof(TestPropertyValidator.DependantOnLookupName)));
            testObject.LookupField = new Lookup("foo", "foo", "Other Record Name");
            Assert.IsFalse(testObject.IsInContext(nameof(TestPropertyValidator.DependantOnLookupName)));
        }
 public void Adding_a_validator_should_store_validator()
 {
     var validator = new TestPropertyValidator();
     builder.SetValidator(validator);
     builder.Rule.CurrentValidator.ShouldBeTheSameAs(validator);
 }
 public void Adding_a_validator_should_store_validator()
 {
     var validator = new TestPropertyValidator();
     builder.SetValidator(validator);
     builder.Cast<IPropertyRule<Person>>().Single().Validator.ShouldBeTheSameAs(validator);
 }