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

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