Example #1
0
        public void RequiredValidator_IsValid_NullPropertyName()
        {
            RequiredValidator validator = new RequiredValidator();
            string            errorMessage;

            Assert.Throws <ArgumentException>(() => validator.IsValid(2, null, this, out errorMessage));
            Assert.Throws <ArgumentException>(() => validator.IsValid(2, String.Empty, this, out errorMessage));
        }
Example #2
0
        public void RequiredValidator_IsValid()
        {
            RequiredValidator validator = new RequiredValidator();
            bool result = validator.IsValid(2, "Foo", this, out string errorMessage);

            Assert.True(result);
            Assert.Null(errorMessage);

            result = validator.IsValid("", "Foo", this, out errorMessage);
            Assert.False(result);
            Assert.NotNull(errorMessage);

            result = validator.IsValid(null, "Foo", this, out errorMessage);
            Assert.False(result);
            Assert.NotNull(errorMessage);
        }