示例#1
0
        public void ShouldNotHaveValidationError_should_throw_when_there_are_validation_errors_ruleforeach()
        {
            ValidationTestException validationTestException = Assert.Throws <ValidationTestException>(() =>
                                                                                                      validator.ShouldNotHaveValidationErrorFor(l => l.NickNames, new[] { "magician", "bull" }));

            Assert.Contains(nameof(Person.NickNames), validationTestException.Message);
        }
示例#2
0
        public void ShouldNotHaveValidationError_should_have_validation_error_details_when_thrown_ruleforeach()
        {
            ValidationTestException validationTestException = Assert.Throws <ValidationTestException>(() =>
                                                                                                      validator.ShouldNotHaveValidationErrorFor(l => l.NickNames, new[] { "magician", "bull" }));

            Assert.Contains("The length of 'Nick Names' must be at least 5 characters. You entered 4 characters.", validationTestException.Message);
        }
        public void ShouldHaveValidationError_should_throw_when_there_are_not_validation_errors_ruleforeach()
        {
            var person = new Person {
                NickNames = new[] { "magician", "awesome" }
            };

            ValidationTestException validationTestException = Assert.Throws <ValidationTestException>(() =>
                                                                                                      validator.TestValidate(person).ShouldHaveValidationErrorFor(l => l.NickNames));

            Assert.Contains(nameof(Person.NickNames), validationTestException.Message);
        }