コード例 #1
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());
        }
コード例 #2
0
        public void Test()
        {
            IAbstractFactory factory  = AssemblyFactory();
            IProductA        productA = factory.Create <IProductA>();
            IProductB        productB = factory.Create <IProductB>();

            Assert.AreEqual <Type>(typeof(ProductA1), productA.GetType());
            Assert.AreEqual <Type>(typeof(ProductB1), productB.GetType());
        }
コード例 #3
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());
        }
コード例 #4
0
        public void AbstractFactoryWithMapperTest()
        {
            IDictionary <Type, Type> dictionary = new Dictionary <Type, Type>();

            dictionary.Add(typeof(IProductA), typeof(ProductA1));
            dictionary.Add(typeof(IProductB), typeof(ProductB1));

            IAbstractFactoryWithMapper factory = new ConcreteFactory(dictionary);
            IProductA productA = factory.Create <IProductA>();
            IProductB productB = factory.Create <IProductB>();

            Assert.AreEqual(typeof(ProductA1), productA.GetType());
            Assert.AreEqual(typeof(ProductB1), productB.GetType());
        }