Beispiel #1
0
        public void TestBuyItemsMethodReflectsCorrectQtyCount()
        {
            SaleLineItem lineItem = new SaleLineItem();

            lineItem.BuyItems(inventory.FindItem(3), 6);
            Assert.AreEqual(6, lineItem.Quantity);
        }
 public void TestThatInventoryReturnsNull_WhenFindItemMethodCalledWithNonExistingUpc()
 {
    Item item1 = new Item("item1", new ItemSpecification(1, new ItemInfo("Good item 1", 23.45M, 34)));
    Item item2 = new Item("item2", new ItemSpecification(2, new ItemInfo("Good item 2", 23.45M, 34)));
    Item item3 = new Item("item3", new ItemSpecification(3, new ItemInfo("Good item 3", 23.45M, 34)));
    Inventory inventory = new Inventory(item1, item2, item3);
    Item found = inventory.FindItem(4);
    Assert.IsNull(found);
 }
 public void TestThatInventoryReturnsTheCorrectItem_WhenFindItemMethodCalledWithItemUpc()
 {
    Item item1 = new Item("item1", new ItemSpecification(1, new ItemInfo("Good item 1", 23.45M, 34)));
    Item item2 = new Item("item2", new ItemSpecification(2, new ItemInfo("Good item 2", 23.45M, 34)));
    Item item3 = new Item("item3", new ItemSpecification(3, new ItemInfo("Good item 3", 23.45M, 34)));
    Inventory inventory = new Inventory(item1, item2, item3);
    Item found = inventory.FindItem(2);
    Assert.AreEqual(item2, found);
 }
        public void BuyItems(int upc, int purchaseQty)
        {
            try
            {
                Item item = inventory.FindItem(upc);
                saleManager.BuyItems(item, purchaseQty);
            }

            //TODO: Add a logger at some point
            catch (ItemNotFoundException)
            {
                //TODO: Add a way to catch logger
            }
        }
 public void TestThatSaleReflectsTotal_ForThreeLineItemsWorthFiveDollarAndQuantityOfSix()
 {
     sale.BuyItems(inventory.FindItem(1), 6);
     sale.BuyItems(inventory.FindItem(2), 6);
     sale.BuyItems(inventory.FindItem(3), 6);
     sale.TotalSale();
     Assert.AreEqual(90M, sale.SaleTotal);
 }
 public void TestThatSaleStateSwitchesToAwaitingPaymentState_WhenTotalled()
 {
     sale.BuyItems(inventory.FindItem(2), 3);
     sale.TotalSale();
     Assert.IsTrue(sale.SaleState is AwaitingPaymentSaleState);
 }