public void TenPercentDiscount()
        {
            // ARRANGE
            SupermarketCatalog catalog = new FakeCatalog();
            var toothbrush             = new Product("toothbrush", ProductUnit.Each);

            catalog.AddProduct(toothbrush, 0.99);
            var apples = new Product("apples", ProductUnit.Kilo);

            catalog.AddProduct(apples, 1.99);

            var cart = new ShoppingCart();

            cart.AddItemQuantity(apples, 2.5);

            var teller = new Teller(catalog);

            teller.AddSpecialOffer(SpecialOfferType.TenPercentDiscount, toothbrush, 10.0);

            // ACT
            var receipt = teller.ChecksOutArticlesFrom(cart);

            // ASSERT
            Assert.Equal(4.975, receipt.GetTotalPrice());
            Assert.Equal(new List <Discount>(), receipt.GetDiscounts());
            Assert.Single(receipt.GetItems());
            var receiptItem = receipt.GetItems()[0];

            Assert.Equal(apples, receiptItem.Product);
            Assert.Equal(1.99, receiptItem.Price);
            Assert.Equal(2.5 * 1.99, receiptItem.TotalPrice);
            Assert.Equal(2.5, receiptItem.Quantity);
        }
示例#2
0
        public void TestSomething()
        {
            SupermarketCatalog catalog = new FakeCatalog();
            var toothbrush             = new Product("toothbrush", ProductUnit.Each);

            catalog.AddProduct(toothbrush, 0.99);
            var apples = new Product("apples", ProductUnit.Kilo);

            catalog.AddProduct(apples, 1.99);

            var cart = new ShoppingCart();

            cart.AddItemQuantity(apples, 2.5);

            var teller = new Teller(catalog);

            teller.AddSpecialOffer(SpecialOfferType.TenPercentDiscount, toothbrush, 10.0);

            var receipt = teller.ChecksOutArticlesFrom(cart);

            Assert.Equal(4.975, receipt.GetTotalPrice());
        }