コード例 #1
0
        public void ValidateCartItemCountAfterRemovingItemsFromCart()
        {
            List <Product> itemsToAdd = new List <Product>()
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Spring Pancake Roll", ProductType.Starter),
                new Product("Roast Barbecued Pork Spare Ribs", ProductType.Starter),
                new Product("Capital Spare Ribs of Pork", ProductType.Starter),
                new Product("King Prawn Chop Suey", ProductType.MainCourse),
                new Product("Sweet & Sour Chicken", ProductType.MainCourse),
                new Product("Chicken Chow Mein", ProductType.MainCourse),
                new Product("Curried King Prawn", ProductType.MainCourse)
            };

            RestaurantCart cart = new RestaurantCart();

            cart.Add(itemsToAdd);

            List <Product> itemsToRemove = new List <Product>()
            {
                new Product("Roast Barbecued Pork Spare Ribs", ProductType.Starter),
                new Product("Capital Spare Ribs of Pork", ProductType.Starter),
                new Product("King Prawn Chop Suey", ProductType.MainCourse),
                new Product("Sweet & Sour Chicken", ProductType.MainCourse)
            };

            cart.Delete(itemsToRemove);
            var updatedcartTotal = cart.GetTotalItemsCount();

            Assert.AreEqual(4, updatedcartTotal);
        }
コード例 #2
0
        public void ValidateCartItemCountAfterUpdatingCartItems()
        {
            List <Product> itemsToAdd = new List <Product>()
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Spring Pancake Roll", ProductType.Starter)
            };

            RestaurantCart cart = new RestaurantCart();

            cart.Add(itemsToAdd);
            var cartTotal = cart.CartTotal();

            List <Product> itemsToUpdate = new List <Product>();

            itemsToUpdate.Add(new Product("Salt & Chilli Smoked Chicken", ProductType.MainCourse));

            cart.Update(itemsToUpdate);
            var updatedcartTotal = cart.GetTotalItemsCount();

            Assert.AreEqual(2, updatedcartTotal);
        }
コード例 #3
0
        public void ValidateCartItemCountOfAddedItems()
        {
            List <Product> products = new List <Product>
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Spring Pancake Roll", ProductType.Starter),
                new Product("Roast Barbecued Pork Spare Ribs", ProductType.Starter),
                new Product("Capital Spare Ribs of Pork", ProductType.Starter),

                new Product("King Prawn Chop Suey", ProductType.MainCourse),
                new Product("Sweet & Sour Chicken", ProductType.MainCourse),
                new Product("Chicken Chow Mein", ProductType.MainCourse),
                new Product("Curried King Prawn", ProductType.MainCourse)
            };

            RestaurantCart cart = new RestaurantCart();

            cart.Add(products);
            var cartTotal = cart.GetTotalItemsCount();

            Assert.AreEqual(8, cartTotal);
        }