Пример #1
0
        public void ShouldAddMultipleTimesToItemQuantity(int first, int second, int expected)
        {
            // Arrange
            var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice);

            // Act
            orderItem.AddQuantity(first);
            orderItem.AddQuantity(second);

            // Assert
            Equal(expected, orderItem.Quantity);
        }
Пример #2
0
        public void ShouldIncreaseDefaultItemQuantityByTheFactorThatIsPassed(int quantity, int expected)
        {
            // Arrange
            var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice);

            // Act
            orderItem.AddQuantity(quantity);

            // Assert
            Equal(expected, orderItem.Quantity);
        }
Пример #3
0
        public void GivenOrderItem_WhenTheQuantityIsAdding_IsSuccessful(int initQuantity, int quantityToAdd)
        {
            // Arrange
            var orderItem = new OrderItem(Guid.NewGuid(), initQuantity);

            // Act
            orderItem.AddQuantity(quantityToAdd);

            // Assert
            Assert.Equal(initQuantity + quantityToAdd, orderItem.Quantity);
        }
Пример #4
0
        public void ShouldThrowArgumentExceptionWhenQuantityIsLessThanOrEqualToZero(int quantity)
        {
            // Arrange
            var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice);

            // Act
            var exception = Throws <ArgumentException>(() => orderItem.AddQuantity(quantity));

            // Assert
            Equal("Invalid quantity", exception.Message);
            Equal(1, orderItem.Quantity);
        }
Пример #5
0
        public void GivenOrderItem_WhenTheNegativeQuantityIsAdding_IsFailed(int quantityToAdd)
        {
            // Arrange
            var orderItem    = new OrderItem(Guid.NewGuid());
            var notification = new Notification();

            // Act
            orderItem.AddQuantity(quantityToAdd);
            orderItem.Validate(notification);

            // Assert
            Assert.False(orderItem.IsValid);
            Assert.True(notification.HasErrors);
        }