コード例 #1
0
        public void ValidateCartTotalAfterRemovingItemsFromCart()
        {
            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.CartTotal();

            Assert.AreEqual(22.8, updatedcartTotal);
        }
コード例 #2
0
        public void NullItemsUpdatedToCart()
        {
            List <Product> products = null;
            RestaurantCart cart     = new RestaurantCart();

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

            Assert.AreEqual(0, cartTotal);
        }
コード例 #3
0
        public void NoItemsInCart()
        {
            List <Product> products = new List <Product>();
            RestaurantCart cart     = new RestaurantCart();

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

            Assert.AreEqual(0, cartTotal);
        }
コード例 #4
0
        public void CartNullCheck()
        {
            List <Product> products = new List <Product>
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Spring Pancake Roll", ProductType.Starter),
            };
            RestaurantCart cart = null;

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

            Assert.AreEqual(0, cartTotal);
        }
コード例 #5
0
        public void RemoveItemsFromEmptyCart()
        {
            List <Product> products = new List <Product>
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Spring Pancake Roll", ProductType.Starter)
            };
            RestaurantCart cart = new RestaurantCart();

            cart.Delete(products);
            var cartTotal = cart.CartTotal();

            Assert.AreEqual(0, cartTotal);
        }
コード例 #6
0
        public void AddSameItemTwiceToCart()
        {
            List <Product> products = new List <Product>
            {
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter),
                new Product("Salt & Chilli Smoked Chicken", ProductType.Starter)
            };

            RestaurantCart cart = new RestaurantCart();

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

            Assert.AreEqual(8.8, cartTotal);
        }
コード例 #7
0
        public void ValidateCartItemCountOfAddedItemsByMenuItemType()
        {
            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.GetItemsCountBy(ProductType.Starter);

            Assert.AreEqual(4, cartTotal);
        }
コード例 #8
0
        public void ValidateCartTotalAfterUpdatingCartItems()
        {
            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 cartTotal2 = cart.CartTotal();

            Assert.AreEqual(11.40, cartTotal2);
        }
コード例 #9
0
        public void DetailedPrintOfAllItemsInCart()
        {
            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.CartTotal();
            var str       = cart.PrintDetailedBill();

            Console.WriteLine(str);
        }