public void IsValid() { var attribute = new CannotBeShorterThanAttribute(3); Assert.AreEqual(true, attribute.IsValid(null)); Assert.AreEqual(true, attribute.IsValid(DBNull.Value)); Assert.AreEqual(false, attribute.IsValid(string.Empty)); Assert.AreEqual(false, attribute.IsValid("a")); Assert.AreEqual(false, attribute.IsValid("aa")); Assert.AreEqual(true, attribute.IsValid("aaa")); Assert.AreEqual(true, attribute.IsValid("aaaa")); }
public void IsValidFail(object value) { var attribute = new CannotBeShorterThanAttribute(3); try { attribute.IsValid(value); Assert.Fail(); } catch (ArgumentException ex) { Assert.AreEqual("Value must be subtype of IEnumerable.", ex.Message); } }