예제 #1
0
        public void Validate_ForNullNotAllowed_Fails()
        {
            // Arrange
            string value = null;
            var    sut   = new StringLengthValidationRule(ERROR_MESSAGE, 20);

            // Act
            var result = sut.Validate(value);

            // Assert
            result.Should().BeFalse();
        }
예제 #2
0
        public void Validate_ForNullAllowed_Pass()
        {
            // Arrange
            string value = null;
            var    sut   = new StringLengthValidationRule(ERROR_MESSAGE, 20, nullIsValid: true);

            // Act
            var result = sut.Validate(value);

            // Assert
            result.Should().BeTrue();
        }
예제 #3
0
        public void Validate_ForMinLength(int length, int valueLength, bool expected)
        {
            // Arrange
            var value = GetValueOfLength(valueLength);
            var sut   = new StringLengthValidationRule(ERROR_MESSAGE, length, checkMaxLength: false);

            // Act
            var result = sut.Validate(value);

            // Assert
            result.Should().Be(expected);
        }