Exemple #1
0
        public void PropertyTypeMatch()
        {
            var model = new ModelPropertyTypeMatch {
                P1 = "Foo", P2 = "Foo"
            };

            var vc1 = new ValidationContext(model, null, null);
            var vr  = new List <ValidationResult>();
            var r   = Validator.TryValidateObject(model, vc1, vr, true);

            Assert.True(r);
            Assert.Equal(0, vr.Count);
        }
        public void PropertyTypeMatch()
        {
            var model = new ModelPropertyTypeMatch {
                P1 = "Foo", P2 = "Foo"
            };

            var vc1 = new ValidationContext(model, null, null);
            var vr  = new List <ValidationResult>();
            var r   = Validator.TryValidateObject(model, vc1, vr, true);

            Assert.False(r);
            Assert.Equal(1, vr.Count);
            Assert.Equal("'P1' and 'P2' must not match.", vr[0].ErrorMessage);
        }