示例#1
0
 public static void ShowReceipt(ICustomer customer, IShoppingBag shoppingBag)
 {
     ShowReceiptTitle(customer, shoppingBag);
     ShowAllAvailableProduct(shoppingBag.GetProductList());
     Console.WriteLine();
     ShowAllAvailableDiscount(customer, shoppingBag);
     Console.WriteLine();
     ShowPayCost(customer, shoppingBag);
     Console.WriteLine("--------------------\n");
 }
示例#2
0
        public double GetTotalDiscount()
        {
            var products           = _shoppingBag.GetProductList();
            var totalFurnitureCost = products.Where(x => x.Name == ProductName.Furniture).Sum(x => x.Price);

            if (totalFurnitureCost < 500)
            {
                return(0);
            }

            return(totalFurnitureCost * _discountPercentage / 100);
        }
示例#3
0
        public void AddProduct_AddingTwoProduct_TotalProductInBagShouldHaveTwo()
        {
            IShoppingBag shoppingBag = GetShoppingBag();

            shoppingBag.AddProduct(GetProduct());
            shoppingBag.AddProduct(GetProduct());
            var products = shoppingBag.GetProductList();
            int expectedTotalProducts = 2;
            int actualTotalProducts   = products.Count();

            Assert.AreEqual(expectedTotalProducts, actualTotalProducts);
        }
示例#4
0
        public double GetTotalDiscount()
        {
            if (_customer.Age < 50)
            {
                return(0);
            }

            var    products          = _shoppingBag.GetProductList();
            double totalMedicineCost = products.Where(x => x.Name == ProductName.Medicine).Sum(x => x.Price);

            return(totalMedicineCost * _discountPercentage / 100);
        }
示例#5
0
        private void During()
        {
            do
            {
                SelectProduct();
                MessageLogger.ShowProductOnShoppingBag(_shoppingBag.GetProductList());
                MessageLogger.AskForContinue();

                if (MessageLogger.AskSelectActivityNumber() == 2)
                {
                    break;
                }
            } while (true);
        }
示例#6
0
        public void RemoveProduct_RemoveProductThatNotInBag_TotalProductShouldNotChange()
        {
            IShoppingBag shoppingBag     = GetShoppingBag();
            IProduct     productInBag    = GetProduct();
            IProduct     productNotInBag = GetProduct();

            shoppingBag.AddProduct(productInBag);
            shoppingBag.RemoveProduct(productNotInBag);
            var products = shoppingBag.GetProductList();
            int expectedTotalProducts = 1;
            int actualTotalProducts   = products.Count();

            Assert.AreEqual(expectedTotalProducts, actualTotalProducts);
        }
示例#7
0
        public double GetTotalDiscount()
        {
            var products          = _shoppingBag.GetProductList();
            int totalSnackProduct = products.Where(x => x.Name == ProductName.Snack).Count();

            if (totalSnackProduct < 3)
            {
                return(0);
            }

            double productCost = products.Where(x => x.Name == ProductName.Snack).FirstOrDefault().Price;

            return(totalSnackProduct / 3 * productCost);
        }
示例#8
0
        public void RemoveProduct_RemoveTwoProductFromTotalFive_TotalProductInBagShouldHaveThree()
        {
            IShoppingBag shoppingBag = GetShoppingBag();
            IProduct     testProduct = GetProduct();

            for (int i = 0; i < 5; i++)
            {
                shoppingBag.AddProduct(testProduct);
            }

            for (int i = 0; i < 2; i++)
            {
                shoppingBag.RemoveProduct(testProduct);
            }

            var products = shoppingBag.GetProductList();
            int expectedTotalProducts = 3;
            int actualTotalProducts   = products.Count();

            Assert.AreEqual(expectedTotalProducts, actualTotalProducts);
        }
示例#9
0
 public double GetTotalCost()
 {
     return(_shoppingBag.GetProductList().Sum(x => x.Price));
 }