예제 #1
0
        public void SingleValidationSuccessTest()
        {
            var validator = ChainingValidator.CreateSimple <int>(source => source < 10);

            // valid source
            validator.Validate(1).IsTrue();
        }
예제 #2
0
        public void SingleValidationFailedTest()
        {
            var validator = ChainingValidator.CreateSimple <int>(source => source < 10);

            // invalid source
            validator.Validate(10).IsFalse();
        }
예제 #3
0
        public void MultiValidationTooSmallTest()
        {
            var validator = ChainingValidator
                            .CreateSimple <int>(source => source < 10)
                            .Add(source => source >= 0);

            validator.Validate(-1).IsFalse();
        }
예제 #4
0
        public void MultiValidationSuccessTest()
        {
            var validator = ChainingValidator
                            .CreateSimple <int>(source => source < 10)
                            .Add(source => source >= 0);

            validator.Validate(5).IsTrue();
        }
예제 #5
0
        public void SimpleEqualsTest()
        {
            var expectedPerson = new Person(20, "Taro");
            var validator      = ChainingValidator.CreateSimple <Person>()
                                 .AddEquals(expectedPerson);

            validator.Validate(new Person(20, "Taro")).IsTrue();
            validator.Validate(new Person(19, "Taro")).IsFalse();
            validator.Validate(new Person(20, "Taroo")).IsFalse();
        }