Ejemplo n.º 1
0
        public void Should_run_validation_when_condition_is_not_set()
        {
            var person = new Person();

            var rule1 = new TestConditionalRule<Person>(true);
            var rule2 = new TestConditionalRule<Person>(false);

            var result1 = rule1.Validate(person);
            var result2 = rule2.Validate(person);

            Assert.That(result1.IsValid, Is.True);
            Assert.That(result2.IsValid, Is.False);
        }
Ejemplo n.º 2
0
        public void Should_always_be_valid_if_condition_is_not_met()
        {
            var person = new Person();

            var rule1 = new TestConditionalRule<Person>(true) { Condition = (p => false) };
            var rule2 = new TestConditionalRule<Person>(false) { Condition = (p => false) };

            var result1 = rule1.Validate(person);
            var result2 = rule2.Validate(person);

            Assert.That(result1.IsValid, Is.True);
            Assert.That(result2.IsValid, Is.True);
        }