예제 #1
0
        /// <summary>
        /// Добавить правило логического умножения для текущей коллекции.
        /// </summary>
        public void And(Action <CollectionValidationBuilder> buildAction)
        {
            var validationOperator = new AndValidator {
                Property = Property
            };

            buildAction(new CollectionValidationBuilder(validationOperator));

            Operator = validationOperator;
        }
        public void Should_Call_IsValid_On_Both_Validators() {
            // Arrange
            var rhs = new Mock<IValidator<string>>();
            rhs.Setup(x => x.IsValid(It.IsAny<string>())).Returns(new ValidationResult {Valid = true});
            var lhs = new Mock<IValidator<string>>();
            lhs.Setup(x => x.IsValid(It.IsAny<string>())).Returns(new ValidationResult {Valid = true});

            // Act
            var compound = new AndValidator<string>(lhs.Object, rhs.Object);
            compound.IsValid(Thumbprint);

            // Assert
            rhs.Verify(x => x.IsValid(It.IsAny<string>()));
            lhs.Verify(x => x.IsValid(It.IsAny<string>()));
        }