示例#1
0
        public void NonRequiredPropertyWithValidSetItemReturnsTrueOnNullProperty()
        {
            // Arrange
            var sut = new ClassWithNonRequiredValidateSetAttributePropertiesAsArray();

            // Act
            var result = sut.IsValid();

            // Assert
            Assert.IsTrue(result);
        }
示例#2
0
        public void NonRequiredPropertyWithValidSetItemReturnsTrue()
        {
            // Arrange
            var sut = new ClassWithNonRequiredValidateSetAttributePropertiesAsArray
            {
                StringPropertyWithValidateSet = "valid-set-item"
            };

            // Act
            var result = sut.IsValid();

            // Assert
            Assert.IsTrue(result);
        }
示例#3
0
        public void ValidateSetReturnsRequiredSetWithErrorMessage()
        {
            // Arrange
            var sut = new ClassWithNonRequiredValidateSetAttributePropertiesAsArray
            {
                StringPropertyWithValidateSet = "invalid-set-item"
            };
            var isValid = sut.IsValid();

            Assert.IsFalse(isValid);

            // Act
            var results = sut.GetValidationResults();

            // Assert
            Assert.AreEqual(1, results.Count);
            var errorMessage = results[0].ErrorMessage;

            Assert.IsTrue(!string.IsNullOrWhiteSpace(errorMessage));

            Assert.IsTrue(errorMessage.Contains("item1|item2|item3|valid-set-item"), errorMessage);
        }