Exemplo n.º 1
0
        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>());
        }
Exemplo 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));
        }