Example #1
0
        public void ConcreteFactory1Test()
        {
            AbstractFactory factory = new ConcreteFactory1();

            Assert.IsInstanceOfType(factory.CreateProductA(), typeof(ProductA1));
            Assert.IsInstanceOfType(factory.CreateProductB(), typeof(ProductB1));
        }
Example #2
0
        public void AbstractFactoryTest()
        {
            IAbstractFactory factory  = new ConcreteFactory1();
            IProductA        productA = factory.CreateProductA();
            IProductB        productB = factory.CreateProductB();

            Assert.AreEqual(typeof(ProductA1), productA.GetType());
            Assert.AreEqual(typeof(ProductB1), productB.GetType());
        }
Example #3
0
        public void Test()
        {
            var factory  = new ConcreteFactory1();
            var product1 = factory.CreateProductA();
            var product2 = factory.CreateProductB();

            Assert.IsTrue(product1 is ProductA1);
            Assert.IsTrue(product2 is ProductB1);
        }
Example #4
0
    static void Main()
    {
        IFactory  factory  = new ConcreteFactory1();
        IProductA productA = factory.CreateProductA();

        productA.ShowA();
        IProductB productB = factory.CreateProductB();

        productB.ShowB();
        Console.ReadKey();
    }