public void ApplyToppingTest() { var pizza = new Pizza(NormalTimes); pizza.ApplyTopping(Topping.GreenPepper); foreach (var slice in pizza.Slices) { Assert.IsTrue(slice.Toppings.Contains(Topping.GreenPepper)); } pizza.ApplyTopping(Topping.Onion); foreach (var slice in pizza.Slices) { Assert.IsTrue(slice.Toppings.Contains(Topping.GreenPepper)); Assert.IsTrue(slice.Toppings.Contains(Topping.Onion)); } }
public void PizzaTest_EndToEnd() { // Make new pizza. var currentState = new List <float> { 1, 1, 1, 1, 1, 1, 1, 2 }; var pizza = new Pizza(currentState); this.ValidatePizza(pizza, currentState); // Can't consume any slices var consumeResult = pizza.ConsumeSlices(new HashSet <Pattern>() { Pattern.A }); Assert.AreEqual(consumeResult.Count, 0); // Bake the pizza pizza.Bake(1); currentState = new List <float>() { 0, 0, 0, 0, 0, 0, 0, 1 }; this.ValidatePizza(pizza, currentState); // Can consume F,G, but not H consumeResult = pizza.ConsumeSlices(new HashSet <Pattern>() { Pattern.F, Pattern.G, Pattern.H }); Assert.AreEqual(consumeResult.Count, 2); currentState = new List <float>() { 0, 0, 0, 0, 0, 1, 1, 1 }; this.ValidatePizza(pizza, currentState); // Add some toppings pizza.ApplyTopping(Topping.Pepperoni); var toppingState = new List <int>() { 1, 1, 1, 1, 1, 1, 1, 1 }; this.ValidatePizza(pizza, currentState, toppingState); // Consume the pizza consumeResult = pizza.ConsumeSlices(new HashSet <Pattern>() { Pattern.A, Pattern.B }); Assert.AreEqual(consumeResult.Count, 2); currentState = new List <float>() { 1, 1, 0, 0, 0, 1, 1, 1 }; toppingState = new List <int>() { 0, 0, 1, 1, 1, 1, 1, 1 }; this.ValidatePizza(pizza, currentState, toppingState); this.ValidateSlices(consumeResult, Topping.Pepperoni); // Bake some more pizza.Bake(1); currentState = new List <float>() { 0, 0, 0, 0, 0, 0, 0, 0 }; this.ValidatePizza(pizza, currentState, toppingState); // Consume A again. Should be plain consumeResult = pizza.ConsumeSlices(new HashSet <Pattern>() { Pattern.A }); Assert.AreEqual(consumeResult.Count, 1); Assert.AreEqual(consumeResult[0].Toppings.Count, 0); // Consume H. Should have toppings (even though it's being baked when the topping was added) consumeResult = pizza.ConsumeSlices(new HashSet <Pattern>() { Pattern.H }); currentState = new List <float>() { 1, 0, 0, 0, 0, 0, 0, 2 }; toppingState = new List <int>() { 0, 0, 1, 1, 1, 1, 1, 0 }; Assert.AreEqual(consumeResult.Count, 1); this.ValidatePizza(pizza, currentState, toppingState); this.ValidateSlices(consumeResult, Topping.Pepperoni); }