public void CheckIfFactoryPreparesGivenFoodTypeTest()
        {
            PastaFactoryWithReflection factory = PastaFactoryWithReflection.Instance;

            factory.Register("vegePasta", typeof(PestoSpaghetti));
            factory.Register("meatPasta", typeof(BologneseSpaghetti));

            var vege = factory.PreparePasta("vegePasta");
            var meat = factory.PreparePasta("meatPasta");

            Assert.That(vege, Is.InstanceOf <PestoSpaghetti>());
            Assert.That(meat, Is.InstanceOf <BologneseSpaghetti>());
        }
Esempio n. 2
0
        public void Setup()
        {
            this.simpleFactory = ChefMariano.Instance;

            this.coffeeFM = CoffeeFactory.Instance;
            this.pizzaFM  = VegePizzaFactory.Instance;

            this.withRegistration = PizzaFactoryWithRegistration.Instance;

            withRegistration.Register("meat", () => new Capriciosa());
            withRegistration.Register("vege", () => new Margherita());

            this.withReflection = PastaFactoryWithReflection.Instance;
            withReflection.Register("meatDish", typeof(BologneseSpaghetti));
            withReflection.Register("vegeDish", typeof(PestoSpaghetti));
        }
Esempio n. 3
0
 public void TearDown()
 {
     this.withReflection   = null;
     this.withRegistration = null;
 }