示例#1
0
        public void When_List_Contains_Fewer_Items_Than_Required_Then_Valid()
        {
            // Arrange
            var maxItemsListAttribute = new MaxItemsListAttribute(2);
            var populatedList         = new object[] { 1 };

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

            // Assert
            isValid.Should().BeTrue();
        }
示例#2
0
        public void When_Object_Is_Not_Enumerable_Then_Exception_Is_Thrown()
        {
            // Arrange
            var inFutureAttribute = new MaxItemsListAttribute(10);
            var notList           = new object();

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

            // Assert
            exception.Should().NotBeNull();
        }
示例#3
0
        public void When_List_Is_Empty_Then_Valid()
        {
            // Arrange
            var maxItemsListAttribute = new MaxItemsListAttribute(2);
            var emptyList             = new object[0];

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

            // Assert
            isValid.Should().BeTrue();
        }
        public void When_Object_Is_Null_Then_Valid()
        {
            // Arrange
            var    maxItemsListAttribute = new MaxItemsListAttribute(1);
            object nullObject            = null;

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

            // Assert
            Assert.IsTrue(isValid);
        }