public void ReturnDefaultValidationType() { // Arrange. IValidationPredicate validationPredicate = new StringNotRegexMatchValidationPredicate("abc"); // Assert. Assert.AreEqual(ValidationType.Default, validationPredicate.ValidationType); }
public void ThrowArgumentNullException_WhenPatternArgumentIsNull() { // Act & Assert. Ensure.ArgumentNullExceptionIsThrown(() => { StringNotRegexMatchValidationPredicate validationPredicate = new StringNotRegexMatchValidationPredicate(null); }, "pattern"); }
public void ThrowArgumentNullException_WhenValueArgumentIsNull() { // Arrange. IValidationPredicate<string> validationPredicate = new StringNotRegexMatchValidationPredicate("abc"); // Act & Assert. Ensure.ArgumentNullExceptionIsThrown(() => { validationPredicate.Match(null); }, "value"); }
public void SetAllGivenProperties() { // Arrange. string pattern = "abc"; // Act. StringNotRegexMatchValidationPredicate validationPredicate = new StringNotRegexMatchValidationPredicate(pattern); // Assert. Assert.AreEqual(pattern, validationPredicate.Pattern); }
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); }