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 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 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)); } } }