public void FactoryCreatorTest() { var af = new AmericanAviationFactory(); var rf = new RussianAviationFactory(); var ah = af.CreateHelicopter(); var at = af.CreateTurbopropPlane(); var ar = af.CreateReactivePlane(); var rh = rf.CreateHelicopter(); var rt = rf.CreateTurbopropPlane(); var rr = rf.CreateReactivePlane(); Assert.AreEqual(ah.GetType(), typeof(Helicopter<GasTurbineEngine>)); Assert.AreEqual(at.GetType(), typeof(Plane<TurbopropEngine>)); Assert.AreEqual(ar.GetType(), typeof(Plane<ReactiveEngine>)); Assert.AreEqual(rh.GetType(), typeof(Helicopter<GasTurbineEngine>)); Assert.AreEqual(rt.GetType(), typeof(Plane<TurbopropEngine>)); Assert.AreEqual(rr.GetType(), typeof(Plane<ReactiveEngine>)); }
private static void FillAer(Aeroport <IPassengerAviation <IEngine> > aer, int planesCount, int heliCount) { IAviationFactory aaf = new AmericanAviationFactory(); IAviationFactory raf = new RussianAviationFactory(); Random r = new Random(); int americanPlanes = r.Next(planesCount); int russianHelicopters = r.Next(heliCount); for (int i = 0; i < planesCount - americanPlanes; ++i) { int reactive = r.Next(2); if (reactive == 1) { aer.Add(raf.CreateReactivePlane()); } else { aer.Add(raf.CreateTurbopropPlane()); } } for (int i = 0; i < americanPlanes; ++i) { int reactive = r.Next(2); if (reactive == 1) { aer.Add(aaf.CreateReactivePlane()); } else { aer.Add(aaf.CreateTurbopropPlane()); } } for (int i = 0; i < russianHelicopters; ++i) { aer.Add(raf.CreateHelicopter()); } for (int i = 0; i < heliCount - russianHelicopters; ++i) { aer.Add(aaf.CreateHelicopter()); } }
public void CreateFactoryTest() { var af = new AmericanAviationFactory(); var rf = new RussianAviationFactory(); }