public void When_Object_Is_Null_Then_Valid()
        {
            // Arrange
            var    notEmptyListAttribute = new NotEmptyListAttribute();
            object nullObject            = null;

            // Act
            var isValid = notEmptyListAttribute.IsValid(nullObject);

            // Assert
            Assert.IsTrue(isValid);
        }
示例#2
0
        public void When_List_Is_Populated_Then_Valid()
        {
            // Arrange
            var notEmptyListAttribute = new NotEmptyListAttribute();
            var populatedList         = new object[] { 1 };

            // Act
            var isValid = notEmptyListAttribute.IsValid(populatedList);

            // Assert
            Assert.IsTrue(isValid);
        }
示例#3
0
        public void When_List_Is_Empty_Then_Invalid()
        {
            // Arrange
            var notEmptyListAttribute = new NotEmptyListAttribute();
            var emptyList             = new object[0];

            // Act
            var isValid = notEmptyListAttribute.IsValid(emptyList);

            // Assert
            Assert.IsFalse(isValid);
        }
示例#4
0
        public void When_Object_Is_Not_Enumerable_Then_Exception_Is_Thrown()
        {
            // Arrange
            var notEmptyListAttribute = new NotEmptyListAttribute();
            var notList = new object();

            // Act
            var exception = Assert.Throws <InvalidOperationException>(() => notEmptyListAttribute.IsValid(notList));

            // Assert
            exception.Should().NotBeNull();
        }