示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
        private void SelectProduct()
        {
            MessageLogger.ShowSelectProductNumber();
            int selectProductNumber = MessageLogger.AskSelectProductNumber();

            switch (selectProductNumber)
            {
            case 1:
                _product = ShoppingFactory.GetProduct(ProductName.Snack, 100);
                break;

            case 2:
                _product = ShoppingFactory.GetProduct(ProductName.Book, 239);
                break;

            case 3:
                _product = ShoppingFactory.GetProduct(ProductName.Furniture, 299);
                break;

            case 4:
                _product = ShoppingFactory.GetProduct(ProductName.KitchenEquipment, 259);
                break;

            case 5:
                _product = ShoppingFactory.GetProduct(ProductName.Medicine, 200);
                break;

            default:
                break;
            }

            int quantity = MessageLogger.AskProductQuantity(_product.Name.ToString());

            for (int i = 0; i < quantity; i++)
            {
                _shoppingBag.AddProduct(_product);
            }
        }