示例#1
0
        public void CustomValidatorErrorMessages()
        {
            var person = new SpecialCustomer1();

            person.FirstName = null;
            person.LastName  = "Test";

            var validator = ValidationBuilder.BuildValidator <Person>();

            var result = validator.Validate(person);

            Assert.That(result.IsValid, Is.False);
            Assert.That(result.Errors.Count(), Is.EqualTo(2));
            Assert.That(
                result.Errors.Select(e => e.ErrorMessage),
                Is.EquivalentTo(new[] { "'LocalizedFirstName' must not be empty.", "'LastName' should not be equal to 'Test'." }));
        }
示例#2
0
        public void CultureIsSetBeforeValidatorIsCreated_UsesNewCultureForLocalization()
        {
            var person = new SpecialCustomer1();

            person.FirstName = null;
            person.LastName  = "value";

            using (new CultureScope("de-AT"))
            {
                var validator = ValidationBuilder.BuildValidator <Person>();

                var result = validator.Validate(person);

                Assert.That(result.IsValid, Is.False);
                Assert.That(
                    result.Errors.Select(e => e.ErrorMessage),
                    Is.EquivalentTo(new[] { "'Lokalisierter Vorname' darf keinen Null-Wert aufweisen." }));
            }
        }
 public void Method(SpecialCustomer1 c1, SpecialCustomer2 c2)
 {
     _baseMap(c1, c2);
     c2.SpecialProperty = c1.SpecialProperty;
 }