public void PrintReceipt_ShoppingCartIsEmpty_ThrowsAnException()
        {
            var receiptPrinter = new ReceiptPrinter();

            //create  empty shopping cart
            var shoppingCart = new ShoppingCart();

            shoppingCart.CartItems = new List <ShoppingCartItem>();

            receiptPrinter.PrintReceipt(shoppingCart);
        }
Esempio n. 2
0
        public void GivenProductWithNoDiscount_WhenPrintReceiptWith_ThenPrintProductPricesOnly()
        {
            Product apples = new Product("apples", ProductUnit.Kilo);

            catalog.AddProduct(apples, 1.99);
            teller = new Teller(catalog);
            cart.AddItemQuantity(apples, 2.5);
            Receipt receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(15);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("apples     4.97\n  1.99 * 2.500\n\nTotal:     4.97\n"));
        }
Esempio n. 3
0
        public void GivenProductWithFiveForAmountDiscount_WhenPrintReceipt_ThenPrintProductPriceAndDiscount()
        {
            var phone = new Product("phone", ProductUnit.Each);

            catalog.AddProduct(phone, 1);
            teller = new Teller(catalog);
            teller.AddSpecialOffer(SpecialOfferType.FiveForAmount, phone, 1.00);
            cart.AddItemQuantity(phone, 10);
            var receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(15);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("phone     10.00\n  1.00 * 10\n5 for 1(phone)-8.00\n\nTotal:     2.00\n"));
        }
Esempio n. 4
0
        public void GivenProductWithTwoForAmountDiscountButLessThanTwoInCart_WhenPrintReceipt_ThenPrintProductPriceOnly()
        {
            Product phone = new Product("phone", ProductUnit.Each);

            catalog.AddProduct(phone, 2);
            teller = new Teller(catalog);
            teller.AddSpecialOffer(SpecialOfferType.TwoForAmount, phone, 1.00);
            cart.AddItemQuantity(phone, 1);
            Receipt receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(15);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("phone      2.00\n\nTotal:     2.00\n"));
        }
Esempio n. 5
0
        public void GivenProductWithThreeForTwoDiscountButLessThanThreeInCart_WhenPrintReceipt_ThenPrintProductPriceOnly()
        {
            Product socks = new Product("socks", ProductUnit.Each);

            catalog.AddProduct(socks, 1);
            teller = new Teller(catalog);
            teller.AddSpecialOffer(SpecialOfferType.ThreeForTwo, socks, 0.00);
            cart.AddItemQuantity(socks, 2);
            Receipt receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(15);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("socks      2.00\n  1.00 * 2\n\nTotal:     2.00\n"));
        }
Esempio n. 6
0
        public void GivenProductWithTenPercentDiscount_WhenPrintReceipt_ThenPrintProductPriceAndDiscount()
        {
            Product dog = new Product("dog", ProductUnit.Each);

            catalog.AddProduct(dog, 0.99);
            teller = new Teller(catalog);
            teller.AddSpecialOffer(SpecialOfferType.TenPercentDiscount, dog, 10.0);
            cart.AddItemQuantity(dog, 2);
            Receipt receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(15);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("dog        1.98\n  0.99 * 2\n10% off(dog)-0.20\n\nTotal:     1.78\n"));
        }
Esempio n. 7
0
        public void GivenCombinationOfProducts_WhenPrintReceipt_ThenPrintProductsWithAndWithoutDiscounts()
        {
            Product bun = new Product("bun", ProductUnit.Kilo);

            catalog.AddProduct(bun, 1);
            Product bin = new Product("bin", ProductUnit.Each);

            catalog.AddProduct(bin, 1);
            teller = new Teller(catalog);
            teller.AddSpecialOffer(SpecialOfferType.TenPercentDiscount, bin, 10.0);
            cart.AddItemQuantity(bun, 5);
            cart.AddItemQuantity(bin, 2);
            Receipt receipt = teller.ChecksOutArticlesFrom(cart);

            ReceiptPrinter receiptPrinter = new ReceiptPrinter(1);

            Assert.That(receiptPrinter.PrintReceipt(receipt),
                        Is.EqualTo("bun5.00\n  1.00 * 5.000\nbin2.00\n  1.00 * 2\n10% off(bin)-0.20\n\nTotal: 6.80\n"));
        }
        public void PrintReceipt_ShoppingCartIsNotEmpty_PrintReceipt()
        {
            var receiptPrinter = new ReceiptPrinter();

            //create shopping cart
            var shoppingCart = new ShoppingCart();

            shoppingCart.CartItems = new List <ShoppingCartItem>();
            var product = new Product
            {
                Name        = "Imported bottle of perfume",
                SalePrice   = 5.60m,
                ProductType = ProductType.Other,
            };

            shoppingCart.CartItems.Add(new ShoppingCartItem
            {
                Product  = product,
                Quantity = 1,
                SaleTax  = 6.00m
            });

            receiptPrinter.PrintReceipt(shoppingCart);
        }
Esempio n. 9
0
        private async void Print(Jq cq)
        {
            await _receiptPrinter.PrintReceipt(cq);

            cq.GetForm("gamocera").Execute(null);
        }