Example #1
0
        public void Invalid_object_fails_validation()
        {
            IValidationRunner runner = new DataAnnotationsValidationRunner();

            ValidationTestObject obj = new ValidationTestObject();

            IEnumerable<RuleViolation> errors = runner.Validate(obj);

            Assert.IsNotNull(errors);
            Assert.AreEqual(2, errors.Count());
        }
Example #2
0
        public void Valid_object_passes_validation()
        {
            IValidationRunner runner = new DataAnnotationsValidationRunner();

            ValidationTestObject obj = new ValidationTestObject()
            {
                Id = 1,
                Name = "Test Object",
                Email = "This is a test object"
            };

            IEnumerable<RuleViolation> errors = runner.Validate(obj);

            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count());
        }