public void AmericanFabricTest() { var fab = new AmericanFactory(); Assert.DoesNotThrow(() => { var gun = fab.CreateGun(TypeOfGun.Tank); Assert.NotNull(gun); var gun1 = fab.CreateGun(TypeOfGun.Artillery); Assert.NotNull(gun1); var armor = fab.CreateArmor(TypeOfArmor.Composite); Assert.NotNull(armor); var armor1 = fab.CreateArmor(TypeOfArmor.Dynamic); Assert.NotNull(armor1); var engine = fab.CreateEngine(TypeOfEngine.Diesel); Assert.NotNull(engine); var engine1 = fab.CreateEngine(TypeOfEngine.Diesel); Assert.NotNull(engine1); }); }
static void Main() { var factory = new AmericanFactory(); var fuuoi = factory.CreateTank(); Console.WriteLine(fuuoi); }
public static void RunRealWorldExample() { ContinentFactory americanFactory = new AmericanFactory(); var americanAnimalWorld = new AnimalWorld(americanFactory); americanAnimalWorld.DescribeAnimalBehavior(); ContinentFactory asianFactory = new AsianFactory(); var asianAnimalWorld = new AnimalWorld(asianFactory); asianAnimalWorld.DescribeAnimalBehavior(); }