示例#1
0
        public void ReturnTheNameOfTheType()
        {
            // Arrange.
            IntValidationPredicateMock validationPredicate = new IntValidationPredicateMock();

            // Act.
            string name = validationPredicate.Name;

            // Assert.
            Assert.AreEqual(validationPredicate.GetType().Name, name);
        }
        public void CallValidateOfT()
        {
            // Arrange.
            IntValidationPredicateMock validationPredicate = new IntValidationPredicateMock();
            object value = 3;

            // Act.
            ((IValidationPredicate)validationPredicate).Match(value);

            // Assert.
            validationPredicate.AssertIsMatchCalls(3);
        }
        public void ReturnValidationPredicateResults_WhenValidatinoPredicatesCollectionIsNotEmpty()
        {
            // Arrange.
            IntValidationPredicateMock validationPredicate1 = new IntValidationPredicateMock();
            IntValidationPredicateMock validationPredicate2 = new IntValidationPredicateMock();
            ValidatableArgument<int> argument = new ValidatableArgument<int>("argument", 5);

            argument.AddValidationPredicate(validationPredicate1);
            argument.AddValidationPredicate(validationPredicate2);

            // Act.
            IEnumerable<IValidationPredicateResult> validationPredicateResults = argument.MatchValidationPredicates();

            // Assert.
            Assert.AreEqual(2, validationPredicateResults.Count());
            validationPredicate1.AssertIsMatchCalls(5);
            validationPredicate2.AssertIsMatchCalls(5);
        }
        public void ReturnValidationPredicateResults_WhenValidatinoPredicatesCollectionIsNotEmpty()
        {
            // Arrange.
            IntValidationPredicateMock validationPredicate1 = new IntValidationPredicateMock();
            IntValidationPredicateMock validationPredicate2 = new IntValidationPredicateMock();
            ValidatableArgument <int>  argument             = new ValidatableArgument <int>("argument", 5);

            argument.AddValidationPredicate(validationPredicate1);
            argument.AddValidationPredicate(validationPredicate2);

            // Act.
            IEnumerable <IValidationPredicateResult> validationPredicateResults = argument.MatchValidationPredicates();

            // Assert.
            Assert.AreEqual(2, validationPredicateResults.Count());
            validationPredicate1.AssertIsMatchCalls(5);
            validationPredicate2.AssertIsMatchCalls(5);
        }