Ejemplo n.º 1
0
        public void IsValid()
        {
            var attribute = new MustBeLowerCaseAttribute();

            Assert.AreEqual(true, attribute.IsValid(null));
            Assert.AreEqual(true, attribute.IsValid(DBNull.Value));
            Assert.AreEqual(true, attribute.IsValid(string.Empty));
            Assert.AreEqual(true, attribute.IsValid(" "));
            Assert.AreEqual(true, attribute.IsValid("abc"));
            Assert.AreEqual(false, attribute.IsValid("ABC"));
            Assert.AreEqual(true, attribute.IsValid("ab1c"));
            Assert.AreEqual(false, attribute.IsValid(" AB 1 C "));
            Assert.AreEqual(true, attribute.IsValid(" ab 1 c "));
        }
Ejemplo n.º 2
0
        public void IsValidFail(object value)
        {
            var attribute = new MustBeLowerCaseAttribute();

            try
            {
                attribute.IsValid(value);

                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Value must be of type String.", ex.Message);
            }
        }