public void IsValid() { var attribute = new CannotBeLongerThanAttribute(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(!false, attribute.IsValid("aaa")); Assert.AreEqual(!true, attribute.IsValid("aaaa")); }
public void IsValidFail(object value) { var attribute = new CannotBeLongerThanAttribute(3); try { attribute.IsValid(value); Assert.Fail(); } catch (ArgumentException ex) { Assert.AreEqual("Value must be subtype of IEnumerable.", ex.Message); } }