コード例 #1
0
        static void Main(string[] args)
        {
            var pizzaMaker = new PizzaMaker(new QuatroFormaggiPizzaBuilder(Crust.Thin, Size.Medium));

            pizzaMaker.BuildPizza();
            Console.WriteLine(pizzaMaker.GetPizza().GetRecipe());

            var pizzaMakerPeperoni = new PizzaMaker(new PeperoniPizzaBuilder(Crust.Thick, Size.Medium));

            pizzaMakerPeperoni.BuildPizza();
            Console.WriteLine(pizzaMakerPeperoni.GetPizza().GetRecipe());
        }
コード例 #2
0
        public void TestBuildingPizza()
        {
            MockPizzaBuilder testBuilder = new MockPizzaBuilder();
            PizzaMaker       pizzaMaker  = new PizzaMaker(testBuilder);

            pizzaMaker.BuildPizza();
            Pizza pizza = pizzaMaker.GetPizza();

            Assert.AreEqual(1, pizza.Id);
            Assert.AreEqual("Test Pizza", pizza.Name);
            Assert.AreEqual(100, pizza.Cost);
            Assert.AreEqual(typeof(Topping), pizza.Toppings.First().GetType());
            Assert.AreEqual(2, pizza.Toppings.Count);
        }