Example #1
0
        public void ThrowArgumentNullException_WhenValueArgumentIsNull()
        {
            // Arrange.
            IValidationPredicate <string> validationPredicate = new StringNotRegexMatchValidationPredicate("abc");

            // Act & Assert.
            Ensure.ArgumentNullExceptionIsThrown(() =>
            {
                validationPredicate.Match(null);
            }, "value");
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }