示例#1
0
        public void IsValid_InputEqualMaxWords_ReturnsTrue(string input)
        {
            // Arrange
            var validator = new MaxWordsValidator(maxWords: 3);

            // Act
            var result = validator.IsValid(value: input);

            // Assert
            Assert.True(result);
        }
示例#2
0
        public void IsValid_EmptyInput_ReturnsTrue()
        {
            // Arrange
            var validator = new MaxWordsValidator(maxWords: 3);

            // Act
            var result = validator.IsValid(value: "");

            // Assert
            Assert.True(result);
        }
示例#3
0
        public void IsValid_InputMoreThanMaxWords_ReturnsFalse()
        {
            // Arrange
            var validator = new MaxWordsValidator(maxWords: 3);
            var input     = "first second third forth";

            // Act
            var result = validator.IsValid(value: input);

            // Assert
            Assert.False(result);
        }
示例#4
0
        public void IsValid_InputLessThanMaxWords_ReturnsTrue()
        {
            // Arrange
            var validator = new MaxWordsValidator(maxWords: 3);
            var input     = "first second";

            // Act
            var result = validator.IsValid(value: input);

            // Assert
            Assert.True(result);
        }
示例#5
0
        public void IsValid_NullInput_ThrowsArgumentNullException()
        {
            // Arrange
            var validator = new MaxWordsValidator(maxWords: 3);

            // Act
            var ex = Record.Exception(() => validator.IsValid(value: null));

            // Assert
            var argException = Assert.IsType <ArgumentNullException>(ex);

            Assert.Equal("value", argException.ParamName);
        }