public void BuyProductTests() { List <Inventory> products = new List <Inventory>(); Inventory item = new Inventory(); Inventory cola = new Inventory("cola", 1.00); Inventory chips = new Inventory("chips", 0.50); products = item.LoadInventory(cola, 5); products = item.LoadInventory(chips, 3, products); Display dis = new Display(); Coins coin = new Coins(5.670, 1.75); dis.AddChange(dis, coin); dis.AddChange(dis, coin); dis.AddChange(dis, coin); dis.AddChange(dis, coin); string name = products.Where(i => i.Name == "chips").First().Name; Assert.True(dis.CanBuyProduct(dis, chips, false)); products = item.BuyProduct(name, products, dis); Assert.Equal(0.50, dis.ChangeReturned); Assert.Equal(2, item.GetInventoryCount(chips, products)); Assert.False(dis.CanBuyProduct(dis, chips, false)); }
public void ReturnChangeTests() { Display dis = new Display(); Coins coin = new Coins(5.670, 1.75); Assert.Equal(0.25, dis.AddChange(dis, coin).ChangeInserted); dis.AddChange(dis, coin); dis.AddChange(dis, coin); dis.AddChange(dis, coin); dis = dis.ReturnChange(dis); Assert.Equal(1, dis.ChangeReturned); Assert.Equal(0, dis.ChangeInserted); }