Пример #1
0
 public void testItemsEnteredOneAtATime()
 {
     CashRegister cr = new CashRegister();
     GrocItem gi_one = new GrocItem("Bread");
     cr.AddItem(gi_one);
     Assert.AreEqual(1, cr.ItemCount);
     GrocItem gi_two = new GrocItem("Milk");
     cr.AddItem(gi_two);
     Assert.AreEqual(2, cr.ItemCount);
 }
Пример #2
0
        public void testAssignItemPrice()
        {
            CashRegister cr = new CashRegister(new PriceService());

            GrocItem giFood = new GrocItem("Burger");
            cr.AddItem(giFood);
            Assert.AreEqual(5.0, cr.Item(0).ItemPrice);

            GrocItem giNonFood = new GrocItem("Tooth Picks");
            cr.AddItem(giNonFood);
            Assert.AreEqual(0.99, cr.Item(1).ItemPrice);
        }
Пример #3
0
        public void testFinalSummaryOutput()
        {
            PriceService ps = new PriceService();
            CashRegister cr = new CashRegister(ps);
            FoodTypeService fts = new FoodTypeService();

            String desiredOut = "Food Items: 2 NonFood Items: 1 Food Tax: 0.24 "
                + "NonFood Tax: 0.14 Subtotal: 9.98 Order Total: 10.36";

            GrocItem giFood1 = new GrocItem("Burger", fts);
            GrocItem giFood2 = new GrocItem("Bread", fts);

            GrocItem giNonFood = new GrocItem("Light Bulb", fts);

            cr.AddItem(giFood1);
            cr.AddItem(giFood2);
            cr.AddItem(giNonFood);

            String receipt = cr.PrintFinalTotals();

            Assert.AreEqual(desiredOut, receipt);
        }
Пример #4
0
        public void testItemTax()
        {
            CashRegister cr = new CashRegister(new PriceService());

            GrocItem giFood = new GrocItem("Burger");
            cr.AddItem(giFood);

            double itemTax = cr.CalcItemTax(giFood);

            Assert.AreEqual(5.00 * 0.03, itemTax);
        }