public void TestProductStockStartsWithFiveOfEachItem() { ProductStock productStock = new ProductStock(); Assert.AreEqual(5, productStock.Count(Products.Cola)); Assert.AreEqual(5, productStock.Count(Products.Chips)); Assert.AreEqual(5, productStock.Count(Products.Candy)); }
public void TestCountCantGoBelowZero() { ProductStock productStock = new ProductStock(); int originalCountAndMore = productStock.Count(Products.Cola) + 3; for (int i = 0; i < originalCountAndMore; i++) { productStock.Remove(Products.Cola); Assert.GreaterOrEqual(productStock.Count(Products.Cola), 0); } }
public void TestHandlesUnknownProductsGracefully() { MockProduct mockProduct = new MockProduct(); ProductStock productStock = new ProductStock(); MockProductStockObserver mockProductStockObserver = new MockProductStockObserver(); productStock.RegisterObserver(mockProductStockObserver); productStock.Remove(mockProduct); Assert.AreEqual(0, productStock.Count(mockProduct)); Assert.AreEqual(0, mockProductStockObserver.NumberOfTimesProductStockUpdatedWasCalled); }
public void TestRemovingACandyDecrementsCountForCandyOnly() { ProductStock productStock = new ProductStock(); productStock.Remove(Products.Candy); Assert.AreEqual(4, productStock.Count(Products.Candy)); Assert.AreEqual(5, productStock.Count(Products.Cola)); Assert.AreEqual(5, productStock.Count(Products.Chips)); productStock.Remove(Products.Candy); Assert.AreEqual(3, productStock.Count(Products.Candy)); Assert.AreEqual(5, productStock.Count(Products.Cola)); Assert.AreEqual(5, productStock.Count(Products.Chips)); }