public void ShouldCreateSpecificPizza() { var sut = SimplePizzaFactory.CreatePizza( PizzaType.NewYork, new List <string>()); Assert.NotNull(sut as NewYorkPizza); }
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); }
public void BuyCheesePizza() { SimplePizzaFactory factory = new SimplePizzaFactory(); PizzaStore store = new PizzaStore(factory); Pizza cheesePizza = store.OrderPizza("cheese"); Pizza clamPizza = new PizzaStore(new SimplePizzaFactory()).OrderPizza("clam"); }
static void Main(string[] args) { SimplePizzaFactory factory = new SimplePizzaFactory(); PizzaStore ps = new PizzaStore(factory); ps.OrderPizza("cheese"); ps.OrderPizza("greek"); }
public void CreateGreekPizza() { SimplePizzaFactory simplePizzaFactory = new SimplePizzaFactory(); PizzaStore store = new PizzaStore(simplePizzaFactory); Pizza greekPizza = store.OrderPizza("greek", Size.Medium); Assert.AreEqual("greek", greekPizza.Name); Assert.AreEqual(Size.Medium, greekPizza.Size); }
public void CreateCheesePizza() { SimplePizzaFactory simplePizzaFactory = new SimplePizzaFactory(); PizzaStore store = new PizzaStore(simplePizzaFactory); Pizza cheesePizza = store.OrderPizza("cheese", Size.Large); Assert.AreEqual("cheese", cheesePizza.Name); Assert.AreEqual(Size.Large, cheesePizza.Size); }
public void CreatePizza() { Pizza pizza = SimplePizzaFactory.CreatePizza(PizzaType.capricciosa); Assert.IsType <Capricciosa>(pizza); pizza = SimplePizzaFactory.CreatePizza(PizzaType.margherita); Assert.IsType <Margherita>(pizza); }
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()); }
public static void Main(string[] args) { SimplePizzaFactory factory = new SimplePizzaFactory(); PizzaStore store = new PizzaStore(factory); Pizza pizza = store.OrderPizza("cheese"); Console.WriteLine("We ordered a " + pizza.Name); pizza = store.OrderPizza("veggie"); Console.WriteLine("We ordered a " + pizza.Name); }
public static IDesignPattern GetInstance(String patternName) { IDesignPattern designPattern; switch (patternName) { case DesignPatternConstants.SINGLETON: designPattern = ChocolateBoiler.GetSynchronizedInstance(); break; case DesignPatternConstants.STRATEGY: designPattern = new MiniDuckSimulator(); break; case DesignPatternConstants.OBSERVER: designPattern = new WeatherStation(); break; case DesignPatternConstants.DECORATOR: designPattern = new StarbuzzCoffee(); break; case DesignPatternConstants.SIMPLE_FACTORY: SimplePizzaFactory factory = new SimplePizzaFactory(); designPattern = new SimpleFactory.PizzaStore.PizzaStore(factory); break; case DesignPatternConstants.FACTORY_METHOD: designPattern = new PizzaStoreFranchisor(); break; case DesignPatternConstants.ABSTRACT_FACTORY: designPattern = new PizzaTestDrive(); break; case DesignPatternConstants.COMMAND: designPattern = new RemoteLoader(); break; case DesignPatternConstants.ADAPTER: designPattern = new DuckTestDrive(); break; case DesignPatternConstants.FACADE: designPattern = new HomeTheaterTestDrive(); break; default: throw new NotImplementedException(); } return(designPattern); }
//SimplePizzaFactory factory; //public SimplePizzaStore(SimplePizzaFactory factory) //{ // this.factory = factory; //} public Pizza OrderPizza(string type) { Pizza pizza; //pizza = factory.CreatePizza(type); pizza = SimplePizzaFactory.CreatePizza(type); pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }
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())); }
static void Main(string[] args) { SimplePizzaFactory nyFactory = new SimplePizzaFactory(); PizzaStore nyStore = new PizzaStore(nyFactory); nyStore.OrderPizza("cheese"); nyStore.OrderPizza("pepperoni"); nyStore.OrderPizza("clam"); nyStore.OrderPizza("veggie"); Console.ReadLine(); }
public static void Factory() { // simple factory var simpleFactory = new SimplePizzaFactory(); var simpleStore = new SimplePizzaStore(simpleFactory); var pizza = simpleStore.OrderPizza("cheese"); pizza = simpleStore.OrderPizza("pepperoni"); // factory method pizza = new CheesePizzaFactory().OrderPizza(); pizza = new PepperoniPizzaFactory().OrderPizza(); }
public void PizzaStore_Can_order_pizzas(PizzaTypes type) { // Arrange var simpleFactory = new SimplePizzaFactory(); var pizzaStore = new PizzaStore(simpleFactory); // Act var pizza = pizzaStore.OrderPizza(type); // Assert Assert.That(pizza, Is.Not.Null); Assert.That(pizza.PizzaType, Is.EqualTo(type.ToString())); }
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"); }
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 }
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; } }
public ChicagoStylePizzaStore(SimplePizzaFactory factory) : base(factory) { }
public ChicagoPizzaStore(SimplePizzaFactory factory) { this._factory = factory; }
public SimplePizzaStore(SimplePizzaFactory factory) { _factory = factory; }
public NyStylePizzaStore(SimplePizzaFactory factory) : base(factory) { }
public NyPizzaStore(SimplePizzaFactory factory) { this._factory = factory; }
public PizzaStore(SimplePizzaFactory pizzaFactory) { this.pizzaFactory = pizzaFactory; }
public PizzaStore(SimplePizzaFactory factory) { this.factory = factory; }
public SimplePizzaStore(SimplePizzaFactory simplePizzaFactory) { this._pizzaFactory = simplePizzaFactory; }
public PizzaStore(SimplePizzaFactory simplePizzaFactory) { _simplePizzaFactory = simplePizzaFactory; }
public PizzaStoreV1(SimplePizzaFactory factory) { Factory = factory; }
public PizzaStore(SimplePizzaFactory factory) { _factory = factory; }
public static void Main(string[] args) { Console.WriteLine("\n\n\r===========Working with Strategy Pattern======="); RedHeadDuck redHeadDuck = new RedHeadDuck(); redHeadDuck.PerformFly(); redHeadDuck.PerformQuack(); redHeadDuck.Swim(); redHeadDuck.Display(); Console.WriteLine("\n\rSetting the Behaviour for Ducks that exibit different Behaviours"); RubberDuck rubberDuck = new RubberDuck(); rubberDuck.PerformFly(); rubberDuck.SetFlyBehaviour(new FlyWithRockets()); rubberDuck.PerformFly(); rubberDuck.PerformQuack(); Console.WriteLine("\n\n\r===========Working with Observer Pattern======="); WeatherData WeatherData = new WeatherData(); ForecastDisplay forcastDisplay = new ForecastDisplay(WeatherData); WeatherData.WeatherMeasurements(15, 20, 25); Console.WriteLine("\n\n\r===========Working with Classic Singleton======="); ClassicSingleton classicSingleton = ClassicSingleton.GetInstance(); classicSingleton.Description(); Console.WriteLine("\n\n\r===========Working with Static Singleton======="); StaticSingleton staticSingleton = StaticSingleton.GetInstance(); staticSingleton.Description(); Console.WriteLine("\n\n\r===========Working with Singleton using syncronization======="); SingletonUsingSyncronization syncronizedSingleton = SingletonUsingSyncronization.GetInstance(); syncronizedSingleton.Description(); Console.WriteLine("\n\n\r===========Working with Factory Design Pattern======="); SimplePizzaFactory factory = new SimplePizzaFactory(); PizzaStore store = new PizzaStore(factory); Pizza pizza = store.OrderPizza("Cheese"); Console.WriteLine(pizza.ToString()); Console.WriteLine("\nState Machine Design Pattern"); GumballMachine machine = new GumballMachine(5); Console.WriteLine(machine); machine.InsertQuarter(); machine.EjectQuarter(); machine.TurnCrank(); Console.WriteLine(machine); Console.WriteLine("\n Working with Iterators"); DinnerMenu dinnerMenu = new DinnerMenu(); DesignPatterns.Iterator.Iterator iterator = dinnerMenu.CreateIterator(); while (iterator.HasNext()) { var current = iterator.Next(); Console.WriteLine(current); } Console.WriteLine("\n============================"); PanCakeHouseMenu panMenu = new PanCakeHouseMenu(); DesignPatterns.Iterator.Iterator panIterator = panMenu.CreateIterator(); while (panIterator.HasNext()) { var current = panIterator.Next(); Console.WriteLine(current); } }