Пример #1
0
        public static void ConfigureTestBaskets(TestContext context)
        {
            testBasket1.AddProduct(bread);
            testBasket1.AddProduct(butter);
            testBasket1.AddProduct(milk);

            testBasket2.AddProduct(bread, 2);
            testBasket2.AddProduct(butter, 2);

            testBasket3.AddProduct(milk, 4);

            testBasket4.AddProduct(bread);
            testBasket4.AddProduct(butter, 2);
            testBasket4.AddProduct(milk, 8);

            testBasket5.AddProduct(bread, 2);
            testBasket5.AddProduct(butter, 6);
            testBasket5.AddProduct(milk, 11);

            testBasket6.AddProduct(butter, 4);

            testBasket2.RegisterDiscountCalculator(breadAndButterDiscount);

            testBasket3.RegisterDiscountCalculator(milkDiscount);

            testBasket4.RegisterDiscountCalculator(milkDiscount);
            testBasket4.RegisterDiscountCalculator(breadAndButterDiscount);

            testBasket5.RegisterDiscountCalculator(milkDiscount);
            testBasket5.RegisterDiscountCalculator(breadAndButterDiscount);

            testBasket6.RegisterDiscountCalculator(milkDiscount);
            testBasket6.RegisterDiscountCalculator(breadAndButterDiscount);
        }
Пример #2
0
        public void NewProductCountIncreasesWhenSecondProductAdded()
        {
            CustomerBasket basket        = new CustomerBasket();
            int            productsToAdd = 5;

            for (int i = 0; i < productsToAdd; i++)
            {
                basket.AddProduct(bread);
            }

            basket.AddProduct(butter);

            int butterCount = basket.Products[butter];

            Assert.AreEqual(butterCount, 1);
        }
Пример #3
0
        public void BasketContainsBreadWhenBreadAdded()
        {
            CustomerBasket basket = new CustomerBasket();

            basket.AddProduct(bread);

            Assert.IsTrue(basket.Products.ContainsKey(bread));
        }
Пример #4
0
        public void BreadCountInBasketIncreasesBy5When5BreadAdded()
        {
            CustomerBasket basket        = new CustomerBasket();
            int            productsToAdd = 5;

            for (int i = 0; i < productsToAdd; i++)
            {
                basket.AddProduct(bread);
            }

            int initialCount = basket.GetProductCount(bread);

            for (int i = 0; i < productsToAdd; i++)
            {
                basket.AddProduct(bread);
            }

            int breadCount = basket.GetProductCount(bread) - initialCount;

            Assert.AreEqual(breadCount, productsToAdd);
        }