public void Test1() { IAbstractFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); IProductXB productXB = factory.Create <IProductXB>(); Assert.IsInstanceOf(typeof(ProductXB1), productXB); factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.IsInstanceOf(typeof(ProductYC1), productYC); }
public void Test1() { IAbstractFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); IProductXB productXB = factory.Create <IProductXB>(); Assert.AreEqual(typeof(ProductXB1), productXB.GetType()); factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.AreEqual(typeof(ProductYC1), productYC.GetType()); }
public void Test() { IAbstarctFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); // °ó¶¨TypeMapper IProductXB productXB = factory.Create <IProductXB>(); Assert.IsNotNull(productXB); Assert.AreEqual <Type>(typeof(ProductXB1), productXB.GetType()); // ²âÊÔÁíÒ»¸öAbstract Factory factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.IsNotNull(productYC); Assert.AreEqual <Type>(typeof(ProductYC1), productYC.GetType()); }