コード例 #1
0
        public void ShouldCalculateThePriceForTheChekedOutItems()
        {
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            int totalPrice = 5;

            IBasket basket = new Basket();
            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            var checkout = new Checkout(basket);

            var actual = checkout.CalculatePriceForcheckOut();
            Assert.That(actual,Is.EqualTo(totalPrice));
        }
コード例 #2
0
        public void ShouldAddSalePriceToTheItem()
        {
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "10", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "20", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
            var basket = new Basket();

            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            Assert.That(item1.SalePrice,Is.EqualTo(5));
            Assert.That(item2.SalePrice,Is.EqualTo(10));

            var checkout = new Checkout(basket);
            var calculatePriceForcheckOut = checkout.CalculatePriceForcheckOut();

            Assert.That(calculatePriceForcheckOut,Is.EqualTo(15));
        }