public void ThrowArgumentNullException_WhenValueArgumentIsNull() { // Arrange. IValidationPredicate <string> validationPredicate = new StringNotRegexMatchValidationPredicate("abc"); // Act & Assert. Ensure.ArgumentNullExceptionIsThrown(() => { validationPredicate.Match(null); }, "value"); }
public void ReturnTrueAndMatchMessage_WhenArgumentIsEmpty() { // Arrange. IValidationPredicate <string> validationPredicate = new StringNotRegexMatchValidationPredicate("abc"); string value = string.Empty; // Act. IValidationPredicateResult result = validationPredicate.Match(value); // Assert. Assert.IsTrue(result.IsMatch); Assert.AreEqual("Argument value <> does not contain a match of the regular expression <abc>.", result.Message); }
public void ReturnFalseAndUnmatchMessage_WhenArgumentContainsMatch() { // Arrange. IValidationPredicate <string> validationPredicate = new StringNotRegexMatchValidationPredicate("abc"); string value = "xxxabcxxx"; // Act. IValidationPredicateResult result = validationPredicate.Match(value); // Assert. Assert.IsFalse(result.IsMatch); Assert.AreEqual("Argument value <xxxabcxxx> contains a match of the regular expression <abc>.", result.Message); }