public void CanRackIsEmptyTest() { int maxInventory = 5; var cr = new CanRack(maxInventory); cr.FillTheCanRack(); foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { for (int i = maxInventory; i >= -1; i--) { // While amount is at least 1 soda, rack is not empty if (i >= 1) { Assert.IsFalse(cr.IsEmpty(f)); } else { Assert.IsTrue(cr.IsEmpty(f)); } cr.RemoveACanOf(f); } } }
public VendingMachine(int inventory, dynamic price) { canRack = new CanRack(inventory); purchasePrice = new PurchasePrice(price); trxBox = new CoinBox(); box = new CoinBox(); }
public VendingMachineViewModel(int inventory, dynamic price) { canRack = new CanRack(inventory); purchasePrice = new PurchasePrice(price); trxBox = new CoinBox(); box = new CoinBox(); canPriceMessage = $"Please deposit {(this.purchasePrice.Price * .01).ToString("C2")}"; MainTitle = "WPF Vending Machine - Assignment 6"; canMakeChange = true; }
public void CanRackFillCanRackTest() { var cr = new CanRack(3); cr.FillTheCanRack(); foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { // Check the filled canRack by flavor Assert.AreEqual(cr.Contents(f).Amount, 3); } }
public void CanRackEmptyRackOfTest() { var cr = new CanRack(3); cr.FillTheCanRack(); // Empty each flavor and confirm amount is zero foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { cr.EmptyCanRackOf(f); Assert.AreEqual(cr.Contents(f).Amount, 0); } }
public void CanRackRemoveACanOfTest() { int maxInventory = 3; var cr = new CanRack(maxInventory); cr.FillTheCanRack(); foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { for (int i = maxInventory; i >= -1; i--) { // Check inventory is decremented by 1 for each iteration but never less than 0 cr.RemoveACanOf(f); Assert.AreEqual(cr.Contents(f).Amount, Math.Max(0, i - 1)); } } }
public void CanRackIsFullTest() { int maxInventory = 5; var cr = new CanRack(maxInventory); foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { for (int i = 1; i <= maxInventory + 2; i++) { cr.AddACanOf(f); // While amount < maxInventory rack is not full if (i < maxInventory) { Assert.IsFalse(cr.IsFull(f)); } else { Assert.IsTrue(cr.IsFull(f)); } } } }
public void CanRackAddACanOfTest() { int maxInventory = 6; var cr = new CanRack(maxInventory); // Attempt to add 3 more cans than the maximum allowed foreach (Flavor f in Enum.GetValues(typeof(Flavor))) { for (int i = 1; i <= maxInventory + 3; i++) { cr.AddACanOf(f); // Check the cans are incrementing up to the max inventory, but not over if (i <= maxInventory) { Assert.AreEqual(cr.Contents(f).Amount, i); } else { Assert.AreNotEqual(cr.Contents(f).Amount, i); } } } }
public void CanRackCtorTest() { var cr = new CanRack(5); Assert.AreEqual(cr.MaxInventory, 5); }