public void GivenNoObject_WhenCreatingNewConsolidateProductItemsShoppingCart_ReturnsAnInstanceOfIShoppingCart()
        {
            // Arrange, Act
            var shoppingCart = new ConsolidateProductItemsShoppingCart();

            // Assert
            Assert.That(shoppingCart, Is.InstanceOf(typeof(IShoppingCart)));
        }
Esempio n. 2
0
        public void GivenEmptyCartAndProduct_WhenUserAddsProductItemsToCart_ThenCartShowsCorrectTotalPrice()
        {
            // Arrange
            var product = new Product("Dove Soap", 39.99);
            var cart    = new ConsolidateProductItemsShoppingCart();

            var firstProductItem = new ProductItem(product, 5);

            cart.AddProductItem(firstProductItem);

            var secondProductItem = new ProductItem(product, 3);

            cart.AddProductItem(secondProductItem);

            // Act
            var productItemFromCart = cart.ProductItems.First();

            // Assert
            Assert.That(productItemFromCart.Quantity, Is.EqualTo(8));
        }
        public void GivenConsolidateProductItemsShoppingCart_WhenAddTwoProductItemsWithSameName_ThenContainsSingleProductItemWithCombinedQuantity()
        {
            // Arrange
            var shoppingCart = new ConsolidateProductItemsShoppingCart();

            var firstProductItem = new Mock <IProductItem>();

            firstProductItem.Setup(pi => pi.Name).Returns("product name");
            firstProductItem.Setup(pi => pi.Quantity).Returns(10);
            IAddableProductItem addableProductItem = new AddableProductItem(firstProductItem.Object);

            var secondProductItem = new Mock <IProductItem>();

            secondProductItem.Setup(pi => pi.Name).Returns("product name");
            secondProductItem.Setup(pi => pi.Quantity).Returns(7);

            // Act
            shoppingCart.AddProductItem(firstProductItem.Object);
            shoppingCart.AddProductItem(secondProductItem.Object);


            // Assert
            Assert.That(shoppingCart.ProductItems.First().Quantity, Is.EqualTo(17));
        }