示例#1
0
        public void Given_CartItem_When_QuantityDecreasedByMoreThanPossible_Then_AlwaysReturnItemWithQuantityOfOne(int decreaseQuantityBy)
        {
            // Arrange
            var product  = new Product("Milk", 1.0m);
            var cartItem = new CartItem(product, 5);

            // Act
            var result = cartItem.DecreaseQuantity(decreaseQuantityBy);

            // Assert
            Assert.NotSame(cartItem, result);
            Assert.Equal(1, result.Quantity);
        }
示例#2
0
        public void Given_CartItem_When_QuantityDecreased_Then_ReturnNewItemWithUpdatedQuantity()
        {
            // Arrange
            var product  = new Product("Milk", 1.0m);
            var cartItem = new CartItem(product, 5);

            // Act
            var result = cartItem.DecreaseQuantity(3);

            // Assert
            Assert.NotSame(cartItem, result);
            Assert.Equal(2, result.Quantity);
        }