public void TeacherCreationTestWithReflectionConcreteFactory2()
        {
            AbstractFactory factory = ConcreteFactory2.GetFactory();
            IPerson         x       = factory.CreatePerson <MathTeacher>();

            Assert.AreSame(x.GetType(), typeof(MathTeacher));
        }
        static void Main()
        {
            var client = new ClientCore();

            Console.WriteLine("");
            Console.WriteLine("Utilizando a Factory 1:");

            var factory1 = new ConcreteFactory1();

            client.Run(factory1);

            Console.WriteLine("");
            Console.WriteLine("Utilizando a Factory 2:");

            var factory2 = new ConcreteFactory2();

            client.Run(factory2);

            Console.WriteLine("");
            Console.WriteLine("Utilizando a Factory 3:");

            var factory3 = new ConcreteFactory3();

            client.Run(factory3);
        }
        public void ArtistCreationWithConcreteFactory2()
        {
            AbstractFactory factory = ConcreteFactory2.GetFactory();
            IPerson         x       = factory.CreateArtist();

            Assert.AreSame(x.GetType(), typeof(Dancer));
        }
Example #4
0
        public void ConcreteFactory2Test()
        {
            AbstractFactory factory = new ConcreteFactory2();

            Assert.IsInstanceOfType(factory.CreateProductA(), typeof(ProductA2));
            Assert.IsInstanceOfType(factory.CreateProductB(), typeof(ProductB2));
        }
        public void TeacherCreationWithConcreteFactory2()
        {
            AbstractFactory factory = ConcreteFactory2.GetFactory();
            IPerson         x       = factory.CreateTeacher();

            Assert.AreSame(x.GetType(), typeof(MathTeacher));
        }
Example #6
0
        private static void ShowAbstractFactory()
        {
            Console.WriteLine("================================================");
            Console.WriteLine("Pattern code (AbstractFactory):");
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Run();

            Console.WriteLine("Real code (AbstractFactory):");
            ContinentFactory africa = new AfricaFactory();
            AnimalWorld      world  = new AnimalWorld(africa);

            world.RunFoodChain();

            ContinentFactory america = new AmericaFactory();

            world = new AnimalWorld(america);
            world.RunFoodChain();
        }
    public static void Main()
    {
        // Abstract factory #1
        AbstractFactory factory1 = new ConcreteFactory1();
        Client          c1       = new Client(factory1);

        c1.Machine1();

        Console.ReadKey();
        // Abstract factory #2
        AbstractFactory factory2 = new ConcreteFactory2();
        Client          c2       = new Client(factory2);

        c2.Machine1();
        Console.ReadKey();

        AbstractFactory factory3 = new ConcreteFactory3();
        Client          c3       = new Client(factory3);

        c3.Machine1();


        // Wait for user input
        Console.ReadKey();
    }
Example #8
0
        public void TestMethodFctB()
        {
            var factory = new ConcreteFactory2();

            Assert.IsTrue(factory.CreateProduitA() is ConcreteProduitA2);
            Assert.IsTrue(factory.CreateProduitB() is ConcreteProduitB2);
        }
        //Structural
        public static void AbstractFactoryStructural()
        {
            // Abstract factory #1

            AbstractFactory factory1 = new ConcreteFactory1();

            Log.WriteLine("{0} has Created", factory1.GetType().Name);


            var client1 = new Client(factory1);

            Log.WriteLine("{0} has Created", client1.GetType().Name);
            Log.WriteLine("Client Create AbstractProductA and AbstractProductB");
            Log.WriteLine("Client Run");
            client1.Run();

            Log.AddSeparator(5);
            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();

            Log.WriteLine("{0} has Created", factory2.GetType().Name);
            var client2 = new Client(factory2);

            Log.WriteLine("{0} has Created", client2.GetType().Name);
            Log.WriteLine("Client Create AbstractProductA and AbstractProductB");
            Log.WriteLine("Client Run");
            client2.Run();
        }
Example #10
0
        static void AbstractFactoryTester()
        {
            #region sample 1
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            var             client1  = new Client(factory1);
            client1.Run();

            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();
            var             client2  = new Client(factory2);
            client2.Run();
            #endregion


            #region sample 2
            ContinentFactory africa = new AfricaFactory();
            var world = new AnimalWorld(africa);
            world.RunFoodChain();

            // Create and run the American animal world
            ContinentFactory america = new AmericaFactory();
            world = new AnimalWorld(america);
            world.RunFoodChain();
            #endregion
        }
        public void DoctorCreationWithConcreteFactory2()
        {
            AbstractFactory factory = ConcreteFactory2.GetFactory();
            IPerson         x       = factory.CreateDoctor();

            Assert.AreSame(x.GetType(), typeof(Dentist));
        }
 public static ConcreteFactory2 getInstance()
 {
     if (instance == null)
     {
         instance = new ConcreteFactory2();
     }
     return(instance);
 }
Example #13
0
        public void Test()
        {
            IAbstractFactory factory  = new ConcreteFactory2();
            IProductA        productA = factory.CreateProducctA();
            IProductB        productB = factory.CreateProducctB();

            Assert.AreEqual <Type>(typeof(ProductA2Y), productA.GetType());
            Assert.AreEqual <Type>(typeof(ProductB2), productB.GetType());
        }
Example #14
0
        public void Test()
        {
            var factory  = new ConcreteFactory2();
            var productA = factory.CreateProducctA();
            var productB = factory.CreateProducctB();

            Assert.IsTrue(productA is ProductA2Y);
            Assert.IsTrue(productB is ProductB2);
        }
    public static void Main()
    {
        AbstractFactory af = new ConcreteFactory1();

        System.Console.WriteLine("Factory1");
        CreateClientWithFactory(af);
        af = new ConcreteFactory2();
        System.Console.WriteLine("Factory2");
        CreateClientWithFactory(af);
    }
Example #16
0
 static void Test1()
 {
     IProduct1 product1 = new ConcreteFacotry1().CreateProduct1();
     IProduct2 product2 = new ConcreteFactory2().CreateProduct2();
     product1.Create();
     product1.Read();
     product1.Update();
     product1.Delete();
     product2.GetName(0);
 }
Example #17
0
        static void Test1()
        {
            IProduct1 product1 = new ConcreteFacotry1().CreateProduct1();
            IProduct2 product2 = new ConcreteFactory2().CreateProduct2();

            product1.Create();
            product1.Read();
            product1.Update();
            product1.Delete();
            product2.GetName(0);
        }
Example #18
0
        public void TestAbstractFactoryTheory()
        {
            var factory1 = new ConcreteFactory1();
            var client1  = new Client(factory1);

            client1.Run();

            var factory2 = new ConcreteFactory2();
            var client2  = new Client(factory2);

            client2.Run();
        }
        public static void EX1()
        {
            AbstractFactory.Exemplo1.AbstractFactory factory = new ConcreteFactory1();

            AbstractFamily1 obj1 = factory.CreateObjetFamily1();
            obj1.Details();

            factory.CreateObjetFamily2().Details();

            factory = new ConcreteFactory2();
            factory.CreateObjetFamily1().Details();
            factory.CreateObjetFamily2().Details();
        }
Example #20
0
        public static void EX1()
        {
            AbstractFactory factory = new ConcreteFactory1();

            AbstractObject createdObject = factory.CreateObjet();

            factory = new ConcreteFactory2();

            AbstractObject createdObject2 = factory.CreateObjet();

            createdObject.ViewDetails();
            createdObject2.ViewDetails();
        }
        public static void Run()
        {
            Console.WriteLine("Abstract Factory Structural Practice");
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Run();
        }
        public static void EX1()
        {
            AbstractFactory factory = new ConcreteFactory1();

            AbstractObject createdObject = factory.CreateObjet();

            factory = new ConcreteFactory2();

            AbstractObject createdObject2 = factory.CreateObjet();

            createdObject.ViewDetails();
            createdObject2.ViewDetails();
        }
        static void Main(string[] args)
        {
            IAbstractFactory factory1 = new ConcreteFactory1();
            Client           client1  = new Client(factory1);

            client1.Launch();

            IAbstractFactory factory2 = new ConcreteFactory2();
            Client           client2  = new Client(factory2);

            client2.Launch();

            Console.Read();
        }
Example #24
0
        public void CreateAndRunAbstractFactory()
        {
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            var             client1  = new Client(factory1);

            client1.Run();

            // Abstract factory #2
            var factory2 = new ConcreteFactory2();
            var client2  = new Client(factory2);

            client2.Run();
        }
Example #25
0
            public static void Test()
            {
                AbstractFactory factory1 = new ConcreteFactory1();
                var             client1  = new Client(factory1);

                client1.Run();

                AbstractFactory factory2 = new ConcreteFactory2();
                var             client2  = new Client(factory2);

                client2.Run();

                Console.ReadKey();
            }
Example #26
0
    void Start()
    {
        // Abstract factory #1
        AbstractFactory factory1 = new ConcreteFactory1();
        Client          client1  = new Client(factory1);

        client1.Run();

        // Abstract factory #2
        AbstractFactory factory2 = new ConcreteFactory2();
        Client          client2  = new Client(factory2);

        client2.Run();
    }
Example #27
0
    public static void Main()
    {
        // Abstractfactory1
        AbstractFactory factory1 = new ConcreteFactory1();
        Client          c1       = new Client(factory1);

        c1.Run();

        // Abstractfactory2
        AbstractFactory factory2 = new ConcreteFactory2();
        Client          c2       = new Client(factory2);

        c2.Run();
    }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Demo()
        {
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            Client client1 = new Client(factory1);
            client1.Run();

            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();
            Client client2 = new Client(factory2);
            client2.Run();

            // Wait for user input
            Console.ReadKey();
        }
Example #29
0
        public static void Run()
        {
            //https://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa

            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            // Abstract factory #2

            var    factory2 = new ConcreteFactory2();
            Client client2  = new Client(factory2);

            client2.Run();
        }
Example #30
0
        static void Main(string[] args)
        {
            // Fábrica Abstrata 1
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            // Fábrica Abstrata 2
            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Run();

            Console.ReadKey();
        }
Example #31
0
        public static void TestAbstractFactory()
        {
            AbstractFactory factory1 = new ConcreteFactory1();
            var             client1  = new Client(factory1);

            AbstractFactory factory2 = new ConcreteFactory2();
            var             client2  = new Client(factory2);

            Assert.AreNotEqual(factory1.GetType().Name, factory2.GetType().Name);
            Assert.AreSame(factory1.GetType().BaseType, factory2.GetType().BaseType);

            Assert.AreSame(client1.GetType(), client2.GetType());

            StringAssert.AreEqualIgnoringCase("ProductB1 interacts with ProductA1", client1.Run(true));
            StringAssert.AreEqualIgnoringCase("ProductB2 interacts with ProductA2", client2.Run(true));
        }
Example #32
0
    public static void Main()
    {
        var factory1 = new ConcreteFactory1();
        var client   = new Client();

        client.SetFactory(factory1);
        client.Run();

        Console.WriteLine();

        var factory2 = new ConcreteFactory2();

        client.SetFactory(factory2);
        client.Run();

        Console.ReadKey();
    }
    // Entry point into console application.
    public static void Main()
    {
        // Abstract factory #1
        AbstractFactory factory1 = new ConcreteFactory1();
        Client          client1  = new Client(factory1);

        client1.Run();

        // Abstract factory #2
        AbstractFactory factory2 = new ConcreteFactory2();
        Client          client2  = new Client(factory2);

        client2.Run();

        // Wait for user input
        Console.ReadKey();
    }
        // "AbstractFactory"
        public void TestAbstractFactoryPattern()
        {
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            var             c1       = new Client(factory1);

            c1.Run();

            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();
            var             c2       = new Client(factory2);

            c2.Run();

            // Wait for user input
            Console.Read();
        }
 public void test02()
 {
     ConcreteFactory2 f2 = new ConcreteFactory2();
     f2.createProductA().method01();
     f2.createProductB().method02();
 }
Example #36
0
    public void test(string[] args)
    {
        AbstractFactory factory1 = new ConcreteFactory1();
        Environment e1 = new Environment(factory1);
        e1.Run();

        AbstractFactory factory2 = new ConcreteFactory2();
        Environment e2 = new Environment(factory2);
        e2.Run();

        Console.Read();
    }