Provides an implementation of the CommonValidator.IValidator interface which relies on NHibernate validator
상속: Shaml.Core.CommonValidator.IValidator
예제 #1
0
        public void CanValidateObject()
        {
            Validator validator = new Validator();

            SomeObject invalidObject = new SomeObject();
            Assert.That(validator.IsValid(invalidObject), Is.False);

            SomeObject validObject = new SomeObject() {
                Name = ""
            };
            Assert.That(validator.IsValid(validObject), Is.True);
        }
예제 #2
0
        public void CanRetriveValiationResults()
        {
            Validator validator = new Validator();

            SomeObject invalidObject = new SomeObject();
            ICollection<IValidationResult> results = validator.ValidationResultsFor(invalidObject);

            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results.First().PropertyName, Is.EqualTo("Name"));
            Assert.That(results.First().ClassContext, Is.EqualTo(typeof(SomeObject)));
            Assert.That(results.First().Message, Is.EqualTo("Dude...the name please!!"));
        }