Пример #1
0
        public void IsValid()
        {
            var attribute = new CannotBeNullOrWhitespaceAttribute();

            Assert.AreEqual(false, attribute.IsValid(null));
            Assert.AreEqual(false, attribute.IsValid(DBNull.Value));
            Assert.AreEqual(false, attribute.IsValid(string.Empty));
            Assert.AreEqual(false, attribute.IsValid(" "));
            Assert.AreEqual(false, attribute.IsValid("\t"));
            Assert.AreEqual(true, attribute.IsValid("aaa"));
        }
Пример #2
0
        public void IsValidFail(object value)
        {
            var attribute = new CannotBeNullOrWhitespaceAttribute();

            try
            {
                attribute.IsValid(value);

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