예제 #1
0
        public void CreateCaliforniaPizza()
        {
            IPizza pizza = SimplePizzaFactory.CreatePizza(Factory.PizzaType.California, new List <string>());

            this.output.WriteLine($"Pizza Type: {pizza.GetType()}");
            Assert.NotNull(pizza as CaliforniaPizza);
        }
예제 #2
0
        public void ShouldCreateSpecificPizza()
        {
            var sut = SimplePizzaFactory.CreatePizza(
                PizzaType.NewYork, new List <string>());

            Assert.NotNull(sut as NewYorkPizza);
        }
        public void CreatePizza()
        {
            Pizza pizza = SimplePizzaFactory.CreatePizza(PizzaType.capricciosa);

            Assert.IsType <Capricciosa>(pizza);

            pizza = SimplePizzaFactory.CreatePizza(PizzaType.margherita);
            Assert.IsType <Margherita>(pizza);
        }
예제 #4
0
        public Pizza OrderPizza(string type)
        {
            var pizza = _factory.CreatePizza(type);

            pizza.Prepare();
            pizza.Bake();
            pizza.Cut();
            pizza.Box();
            return(pizza);
        }
예제 #5
0
        public Pizza OrderPizza(string type)
        {
            Pizza pizza = _simplePizzaFactory.CreatePizza(type);

            pizza.Prepare();
            pizza.Bake();
            pizza.Cut();
            pizza.Box();

            return(pizza);
        }
예제 #6
0
        public Pizza OrderPizza(string type)
        {
            Pizza pizzaBase = Factory.CreatePizza(type);

            pizzaBase.Prepare();
            pizzaBase.Bake();
            pizzaBase.Cut();
            pizzaBase.Box();

            return(pizzaBase);
        }
예제 #7
0
        public void SimpleFactoryUT_TestPepperoniPizza()
        {
            IPizza             pizza;
            SimplePizzaFactory pizzaFactory = new SimplePizzaFactory();

            pizza = pizzaFactory.CreatePizza("Pepperoni");
            Assert.AreEqual("Preparing Pepperoni Pizza\n", pizza.Prepare());
            Assert.AreEqual("Cutting Pepperoni Pizza\n", pizza.Cut());
            Assert.AreEqual("Baking Pepperoni Pizza\n", pizza.Bake());
            Assert.AreEqual("Boxing Pepperoni Pizza\n", pizza.Box());
        }
예제 #8
0
        public void SimplePizzaFactory_Can_create_pizzas(PizzaTypes type)
        {
            // Arrange

            var simpleFactory = new SimplePizzaFactory();

            // Act
            var pizza = simpleFactory.CreatePizza(type);

            // Assert
            Assert.That(pizza, Is.Not.Null);
            Assert.That(pizza.PizzaType, Is.EqualTo(type.ToString()));
        }
예제 #9
0
        public Pizza OrderPizza(string type)
        {
            Pizza pizza;

            pizza = pizzaFactory.CreatePizza(type);

            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

            return(pizza);
        }
예제 #10
0
        public Pizza OrderPizza(string type)
        {
            Pizza pizza = factory.CreatePizza(type);

            if (pizza != null)
            {
                pizza.Prepare();
                pizza.Bake();
                pizza.Cut();
                pizza.Box();
            }
            return(pizza);
        }
        public Pizza OrderPizza(PizzaType pizzaType)
        {
            Pizza pizza;

            pizza = _factory.CreatePizza(pizzaType);

            pizza.Prepare();
            pizza.Bake();
            pizza.Cut();
            pizza.Box();

            return(pizza);
        }
예제 #12
0
        public Pizza OrderPizza(string type)
        {
            //通过类型获取pizza
            Pizza pizza = _factory.CreatePizza(type);

            if (pizza != null)
            {
                pizza.Prepare();
                pizza.Bake();
                pizza.Cut();
                pizza.Box();
                Console.WriteLine($"{type} Done!!!");
            }
            else
            {
                Console.WriteLine("We don't have this kind of pizza!!");
            }

            return(pizza);
        }
예제 #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Console.WriteLine("What Piza do you you want");

            string answer = Console.ReadLine();

            SimplePizzaFactory spf = new SimplePizzaFactory();

            Pizza pizza = spf.CreatePizza("Cheese");

            pizza.Prepare();
            pizza.Bake();
            pizza.Box();

            Zeeks zeeks = new Zeeks();

            zeeks.OrderPizza("Cheese");
        }
예제 #14
0
        static void Main(string[] args)
        {
            #region simple factory
            //Simple factory; geen interfaces, geen abstract classes, allemaal simpele implementaties.
            var simplePizzaFactory = new SimplePizzaFactory();
            var pizza = simplePizzaFactory.CreatePizza();
            #endregion



            #region method factory
            //method factory; geen interfaces, geen abstract classes, allemaal simpele implementaties.
            var margheritaPizzaFactory = new PizzaMargheritaFactory();
            var margherita             = margheritaPizzaFactory.CreatePizza();
            #endregion


            #region abstract factory (builder pattern in background)
            //Abstract factory; iedere van de aangemaakte 'soorten' objecten zijn aan elkaar gerelateerd per factory.
            //Bijvoorbeeld een Auto, Vliegtuig en

            //Create several bicycle objects; common in that they have two wheels.
            var bicycleFactory = new BicycleFactory();

            var motorcycle      = bicycleFactory.CreateGasolinePowered();
            var colinFurzesBike = bicycleFactory.CreateJetPowered(); //Deze fiets is speciaal; hij heeft ook pedalen.
            var bike            = bicycleFactory.CreatePeddlePowered();

            //Create several leased cars, common in that they have four wheels, are gray, and may be a bit boring.
            var carFactory = new LeaseCarFactory();

            var leaseCar   = carFactory.CreateGasolinePowered();
            var leisureCar = carFactory.CreateJetPowered();

            //Create some planes
            var planeFactory   = new AirplaneFactory();
            var propellerPlane = planeFactory.CreateGasolinePowered();
            var corporateJet   = planeFactory.CreateJetPowered();

            #endregion
        }
예제 #15
0
        public void ShouldCreateSpecificPizza(Factory.PizzaType pizzaType)
        {
            IPizza pizza = SimplePizzaFactory.CreatePizza(pizzaType, new List <string>());

            this.output.WriteLine($"Pizza Type: {pizza.GetType()}");

            switch (pizzaType)
            {
            case Factory.PizzaType.California:
                Assert.NotNull(pizza as CaliforniaPizza);
                break;

            case Factory.PizzaType.Chicago:
                Assert.NotNull(pizza as ChicagoPizza);
                break;

            case Factory.PizzaType.NewYork:
                Assert.NotNull(pizza as NewYorkPizza);
                break;
            }
        }
예제 #16
0
        public void OrderPizza(string pizzaName)
        {
            /* The code commented below is tightly coupled and breaks the OCP */

            //if (pizzaName == "cheese")
            //{
            //    _pizaa = new CheesePizza();
            //}
            //if (pizzaName == "peppypaneer")
            //{
            //    _pizaa = new PeppypaneerPizza();
            //}
            //if (pizzaName == "farmhouse")
            //{
            //    _pizaa = new FarmhousePizza();
            //}

            Pizza pizza = _simplePizzaFactory.CreatePizza(pizzaName);

            pizza.Prepare();
            pizza.Bake();
            pizza.Cut();
            pizza.Box();
        }
        public Pizza CreatePizza(PizzaType pizzaType)
        {
            var pizza = _factory.CreatePizza(pizzaType);

            return(pizza);
        }