public void AddSurplusRice() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.ALaCarte; _ = nacho.AddIngredient(UnitTestItems.Ingredients.Rice); // Add rice ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.Rice); // Add more rice! Assert.IsFalse(result.Success); Assert.AreEqual("Only 1 serving of rice per meal", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AlaCarteCosts3() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.ALaCarte; nacho.AddIngredient(UnitTestItems.Ingredients.Tortilla); nacho.AddIngredient(UnitTestItems.Ingredients.Rice); nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); nacho.AddIngredient(UnitTestItems.Ingredients.Steak); nacho.AddIngredient(UnitTestItems.Ingredients.RedSalsa); nacho.AddIngredient(UnitTestItems.Ingredients.Queso); nacho.AddIngredient(UnitTestItems.Ingredients.GratedCheese); nacho.AddIngredient(UnitTestItems.Ingredients.Guacamole); Order order = new Order(); order.AddItem(nacho); int result = order.Total; int expected = 732; Assert.AreEqual(expected, result); UnitTestItems.ClearSelectedIngredients(); }
public void AddSecondMeatItem() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNacho; // Allowed: 1 meat, 1 salsa _ = nacho.AddIngredient(UnitTestItems.Ingredients.Steak); // Add 1 meat item ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); // Try to add a second meat item Assert.IsFalse(result.Success); Assert.AreEqual("Nachos are limited to 1 meat option per meal.", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AddItemToOrder() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNachoInBowl; nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); nacho.AddIngredient(UnitTestItems.Ingredients.GreenSalsa); Order order = new Order(); ProcessResult result = order.AddItem(nacho); Assert.IsTrue(result.Success); UnitTestItems.ClearSelectedIngredients(); }
public void AddForbiddenIngredient() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNacho; // Allowed: 1 meat, 1 salsa _ = nacho.AddIngredient(UnitTestItems.Ingredients.Steak); //Add 1 meat _ = nacho.AddIngredient(UnitTestItems.Ingredients.Queso); //Add 1 Salsa ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.GratedCheese); // Try to add a topping Assert.IsFalse(result.Success); Assert.AreEqual("Can't add any more ingredients!", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AddMoreThanWholeItemAllows() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.ThreeIngredientNacho; // Allowed: 1 meat, 1 salsa, 1 topping _ = nacho.AddIngredient(UnitTestItems.Ingredients.Steak); // Add 1 meat _ = nacho.AddIngredient(UnitTestItems.Ingredients.Queso); // Add 1 salsa _ = nacho.AddIngredient(UnitTestItems.Ingredients.GratedCheese); // Add 1 topping ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.GreenSalsa); // Try to add another salsa Assert.IsFalse(result.Success); Assert.AreEqual("Can't add any more ingredients!", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AddTooMuchOfOneIngredient() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.ThreeIngredientNacho; // Allowed: 1 meat, 1 salsa, 1 topping _ = nacho.AddIngredient(UnitTestItems.Ingredients.Steak); // Add 1 meat _ = nacho.AddIngredient(UnitTestItems.Ingredients.Queso); // Add 1 salsa // Still allowed to add a topping ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.GreenSalsa); // Try to add another salsa Assert.IsFalse(result.Success); Assert.AreEqual("Can't add any more of this item!", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AttemptToRemoveNonexistentOrderItem() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNachoInBowl; nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); nacho.AddIngredient(UnitTestItems.Ingredients.GreenSalsa); Order order = new Order(); ProcessResult result = order.RemoveItem(nacho); Assert.IsFalse(result.Success); Assert.AreEqual("Item does not exist in this order.", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void AlaCarteCosts2() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.ALaCarte; nacho.AddIngredient(UnitTestItems.Ingredients.Tortilla); nacho.AddIngredient(UnitTestItems.Ingredients.Rice); nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); nacho.AddIngredient(UnitTestItems.Ingredients.RedSalsa); nacho.AddIngredient(UnitTestItems.Ingredients.GreenSalsa); nacho.AddIngredient(UnitTestItems.Ingredients.SourCream); Order order = new Order(); order.AddItem(nacho); int result = order.Total; int expected = 632; Assert.AreEqual(expected, result); UnitTestItems.ClearSelectedIngredients(); }
/// <summary> /// An order consisting of two nacho items, an a-la-carte nacho, and two basic items. /// </summary> /// <returns></returns> public static Order GetSimulatedOrderItem() { NachoItem nachosBowl = NachoItems.TwoIngredientNachoInBowl; // Price 399 _ = nachosBowl.AddIngredient(Ingredients.Chicken); _ = nachosBowl.AddIngredient(Ingredients.RedSalsa); NachoItem nachos = NachoItems.ThreeIngredientNacho; // Price 749 _ = nachos.AddIngredient(Ingredients.Chicken); _ = nachos.AddIngredient(Ingredients.Queso); _ = nachos.AddIngredient(Ingredients.GratedCheese); NachoItem nachoALaCarte = NachoItems.ALaCarte; // Price 732 _ = nachoALaCarte.AddIngredient(Ingredients.Tortilla); _ = nachoALaCarte.AddIngredient(Ingredients.Rice); _ = nachoALaCarte.AddIngredient(Ingredients.Steak); _ = nachoALaCarte.AddIngredient(Ingredients.Steak); _ = nachoALaCarte.AddIngredient(Ingredients.RedSalsa); _ = nachoALaCarte.AddIngredient(Ingredients.Queso); _ = nachoALaCarte.AddIngredient(Ingredients.GratedCheese); _ = nachoALaCarte.AddIngredient(Ingredients.Guacamole); BasicItem chips = BasicItems.Chips; // Price 200 BasicItem cola = BasicItems.SoftDrink; // Price 125 Order order = new Order(); _ = order.AddItem(nachosBowl); _ = order.AddItem(nachos); _ = order.AddItem(nachoALaCarte); _ = order.AddItem(chips); _ = order.AddItem(cola); return(order); // Total 2205 }
public void RemoveIngredientSelection() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNachoInBowl; _ = nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); ProcessResult result = nacho.RemoveIngredient(UnitTestItems.Ingredients.Chicken); Assert.IsTrue(result.Success); UnitTestItems.ClearSelectedIngredients(); }
public void AddTortillaWhenNotAllowed() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNachoInBowl; // Tortilla NOT included! ProcessResult result = nacho.AddIngredient(UnitTestItems.Ingredients.Tortilla); // Try to add torilla Assert.IsFalse(result.Success); Assert.AreEqual("This product does not include tortilla.", result.Message); UnitTestItems.ClearSelectedIngredients(); }
public void RemoveWrongIngredientSelection() { UnitTestItems.ClearSelectedIngredients(); NachoItem nacho = UnitTestItems.NachoItems.TwoIngredientNachoInBowl; _ = nacho.AddIngredient(UnitTestItems.Ingredients.Chicken); ProcessResult result = nacho.RemoveIngredient(UnitTestItems.Ingredients.Steak); //doesn't exist! Assert.IsFalse(result.Success); Assert.AreEqual("This ingredient was not added to this menu item.", result.Message); UnitTestItems.ClearSelectedIngredients(); }