コード例 #1
0
        public void ShouldRemoveLastProductInCart()
        {
            Product[] products =
            {
              new Product("Milk", 12.10m),
              new Product("Meat", 14.15m)
            };

            ShoppingCart cart = new ShoppingCart(products);
            cart.RemoveLastProductFromCart();
            Assert.AreEqual(1, cart.GetLength());
        }
コード例 #2
0
        public void ShouldAddAProductToCart()
        {
            Product bread = new Product("Bread", 10.12m);

            Product[] products =
            {
              new Product("Milk", 12.10m)
            };

            ShoppingCart cart = new ShoppingCart(products);
            cart.AddProductToCart(bread);

            Assert.AreEqual(2, cart.GetLength());
        }
コード例 #3
0
        public void ShouldRemoveMostExpensiveProductFromCart()
        {
            Product[] products =
            {
              new Product("Milk", 12.10m),
              new Product("Meat", 14.15m),
              new Product("Water", 12.50m),
              new Product("Bread", 10.12m)
            };

            ShoppingCart cart = new ShoppingCart(products);
            cart.FindAndRemoveMostExpensiveProduct();
            Assert.AreEqual(3, cart.GetLength());
            Assert.AreEqual("Milk", products[0].GetName());
            Assert.AreEqual("Bread", products[1].GetName());
            Assert.AreEqual("Water", products[2].GetName());
        }