public static void MenuDuplicatePizza(OrderBuilder ob) { string input = ""; bool inputValid = false; do { MenuHelperSelectPizza("duplicate", "pizza", ob.CurOrder.Pizzas); Console.Write("->"); input = Console.ReadLine(); inputValid = !input.Any(c => !char.IsDigit(c)) && Int32.Parse(input) >= 1 && Int32.Parse(input) <= ob.CurOrder.Pizzas.Count; if (!inputValid) { Console.WriteLine("That selection is invalid. Enter only the number associated with the pizza you wish to duplicate. Please try again."); } }while (!inputValid && !input.Equals("0")); var targetPizza = ob.CurOrder.Pizzas[Int32.Parse(input) - 1]; var newPizza = new Pizza(targetPizza.Size); newPizza.CrustType = targetPizza.CrustType; newPizza.SauceType = targetPizza.SauceType; foreach (var t in targetPizza.Toppings) { newPizza.Toppings.Add(t); } newPizza.Price = targetPizza.Price; ob.AddPizza(newPizza); }
public void AddPizzaShouldDoNothingIfPassedNullIPizza() { OrderBuilder ob = new OrderBuilder("user", "store"); ob.CurOrder.Pizzas.Add(new Pizza("medium")); ob.AddPizza(null); Assert.True(ob.CurOrder.Pizzas.Count == 1); }
public void AddPizzaShouldAddExactlyOneAdditionalPizzaToPizzas() { OrderBuilder ob = new OrderBuilder("user", "store"); ob.CurOrder.Pizzas.Add(new Pizza("small")); ob.AddPizza(new Pizza("small")); Assert.True(ob.CurOrder.Pizzas.Count == 2); }
public void AddPizzaShouldAddExactPizzaToEndOfPizzas() { OrderBuilder ob = new OrderBuilder("user", "store"); Pizza p = new Pizza("small"); ob.CurOrder.Pizzas.Add(new Pizza("medium")); ob.AddPizza(p); Pizza result = ob.CurOrder.Pizzas[ob.CurOrder.Pizzas.Count - 1]; Assert.Equal(result, p); }