public void AbstractMethodTest() { IComputadorFactory computadorFactory = new WindowsFactory(); var pcWindows = computadorFactory.CrearComputadorPC("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(pcWindows.GetType().Name); TestContext.WriteLine(pcWindows.ObtenerHDD()); TestContext.WriteLine(pcWindows.ObtenerRam()); TestContext.WriteLine(pcWindows.ObtenerCPU()); var serverWindows = computadorFactory.CrearComputadorServidor("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(serverWindows.GetType().Name); TestContext.WriteLine(serverWindows.ObtenerHDD()); TestContext.WriteLine(serverWindows.ObtenerRam()); TestContext.WriteLine(serverWindows.ObtenerCPU()); computadorFactory = new MacFactory(); var pcMac = computadorFactory.CrearComputadorPC("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(pcMac.GetType().Name); TestContext.WriteLine(pcMac.ObtenerHDD()); TestContext.WriteLine(pcMac.ObtenerRam()); TestContext.WriteLine(pcMac.ObtenerCPU()); var serverMac = computadorFactory.CrearComputadorServidor("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(serverMac.GetType().Name); TestContext.WriteLine(serverMac.ObtenerHDD()); TestContext.WriteLine(serverMac.ObtenerRam()); TestContext.WriteLine(serverMac.ObtenerCPU()); computadorFactory = new LinuxFactory(); var pcLinux = computadorFactory.CrearComputadorPC("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(pcLinux.GetType().Name); TestContext.WriteLine(pcLinux.ObtenerHDD()); TestContext.WriteLine(pcLinux.ObtenerRam()); TestContext.WriteLine(pcLinux.ObtenerCPU()); var serverLinux = computadorFactory.CrearComputadorServidor("2 GB", "500 GB", "2.4 Ghz"); TestContext.WriteLine(serverLinux.GetType().Name); TestContext.WriteLine(serverLinux.ObtenerHDD()); TestContext.WriteLine(serverLinux.ObtenerRam()); TestContext.WriteLine(serverLinux.ObtenerCPU()); Assert.IsTrue(pcLinux is Pc); Assert.IsTrue(serverLinux is Server); Assert.IsTrue(pcWindows is Pc); Assert.IsTrue(serverWindows is Server); Assert.IsTrue(pcMac is Pc); Assert.IsTrue(serverMac is Server); }
public Factory() { // Ensure we are correctly initialized. Toolkit.Init(); // Create regular platform backend #if SDL2 if (Configuration.RunningOnSdl2) { Default = new Sdl2Factory(); } #endif #if WIN32 else if (Configuration.RunningOnWindows) { Default = new Windows.WinFactory(); } #endif #if CARBON else if (Configuration.RunningOnMacOS) { Default = new MacOS.MacOSFactory(); } #endif #if X11 else if (Configuration.RunningOnX11) { Default = new X11Factory(); } else if (Configuration.RunningOnLinux) { Default = new LinuxFactory(); } #endif if (Default == null) { Default = new UnsupportedPlatform(); } // Create embedded platform backend for EGL / OpenGL ES. // Todo: we could probably delay this until the embedded // factory is actually accessed. This might improve startup // times slightly. if (Configuration.RunningOnSdl2) { // SDL supports both EGL and desktop backends // using the same API. Embedded = Default; } #if IPHONE else if (Configuration.RunningOnIOS) { Embedded = new iPhoneOS.iPhoneFactory(); } #else else if (Egl.Egl.IsSupported) { if (Configuration.RunningOnLinux) { Embedded = Default; } #if X11 else if (Configuration.RunningOnX11) { Embedded = new EglX11PlatformFactory(); } #endif #if WIN32 else if (Configuration.RunningOnWindows) { Embedded = new Egl.EglWinPlatformFactory(); } #endif #if CARBON else if (Configuration.RunningOnMacOS) { Embedded = new Egl.EglMacPlatformFactory(); } #endif #if ANDROID else if (Configuration.RunningOnAndroid) { Embedded = new Android.AndroidFactory(); } #endif else { Embedded = new UnsupportedPlatform(); } #if ANDROID Angle = new UnsupportedPlatform(); #else Angle = new EglAnglePlatformFactory(Embedded); #endif } #endif else { Embedded = new UnsupportedPlatform(); Angle = Embedded; } if (Default is UnsupportedPlatform && !(Embedded is UnsupportedPlatform)) { Default = Embedded; } }