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()); }
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()); }
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()); }
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()); }