示例#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);
        }