public void IsValid() { var attribute = new MustBeValidDirectoryPathAttribute(); 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(" ")); Assert.AreEqual(true, attribute.IsValid("abc")); Assert.AreEqual(true, attribute.IsValid(@"C:\Windows\tmp")); Assert.AreEqual(false, attribute.IsValid(@"C:\Wi|ndows\tmp")); }
public void IsValidFail(object value) { var attribute = new MustBeValidDirectoryPathAttribute(); try { attribute.IsValid(value); Assert.Fail(); } catch (ArgumentException ex) { Assert.AreEqual("Value must be of type String.", ex.Message); } }