public void IsValidThrowsExceptionIfPropertyNameIsNotSet() { // Arrange var r = new RequiredRule("ARuleName"); // Act r.IsValid(new Dictionary <string, string>() { { "AProperty", "Blah" } }); }
public void IsValidReturnsTrueWithNonNullString() { // Arrange var r = new RequiredRule("ARuleName").Property("APropertyName"); // Act var result = r.IsValid(new Dictionary <string, string>(1) { { "APropertyName", "This is not a null string." } }); // Assert Assert.IsTrue(result); Assert.IsNull(r.ErrorMessage); }
private void TestIsValidWithNullEquivalent(string Value) { // Arrange var r = new RequiredRule("ARuleName").Property("APropertyName"); // Act var result = r.IsValid(new Dictionary <string, string>(1) { { "APropertyName", Value } }); // Assert Assert.IsFalse(result); Assert.AreEqual("APropertyName is required, but is null, an empty string, or whitespace.", r.ErrorMessage); }