From 5c7cb5dedb21e468338f14177e43426541f0005e Mon Sep 17 00:00:00 2001 From: Charlie Poole Date: Mon, 8 Oct 2012 16:12:43 -0700 Subject: [PATCH] Add MacOsX and Xbox to platform attribute --- src/NUnitCore/core/PlatformHelper.cs | 12 ++++++++++++ src/NUnitCore/interfaces/OSPlatform.cs | 18 ++++++++++++++++++ src/NUnitCore/tests/PlatformDetectionTests.cs | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/NUnitCore/core/PlatformHelper.cs b/src/NUnitCore/core/PlatformHelper.cs index 593c83ea..cd01f99a 100644 --- a/src/NUnitCore/core/PlatformHelper.cs +++ b/src/NUnitCore/core/PlatformHelper.cs @@ -21,7 +21,11 @@ namespace NUnit.Core /// Comma-delimited list of all supported OS platform constants /// public static readonly string OSPlatforms = +#if CLR_2_0 || CLR_4_0 + "Win,Win32,Win32S,Win32NT,Win32Windows,WinCE,Win95,Win98,WinMe,NT3,NT4,NT5,NT6,Win2K,WinXP,Win2003Server,Vista,Win2008Server,Win2008ServerR2,Win2012Server,Windows7,Windows8,Unix,Linux,Xbox,MacOSX"; +#else "Win,Win32,Win32S,Win32NT,Win32Windows,WinCE,Win95,Win98,WinMe,NT3,NT4,NT5,NT6,Win2K,WinXP,Win2003Server,Vista,Win2008Server,Win2008ServerR2,Win2012Server,Windows7,Windows8,Unix,Linux"; +#endif /// /// Comma-delimited list of all supported Runtime platform constants @@ -198,6 +202,14 @@ namespace NUnit.Core case "LINUX": isSupported = os.IsUnix; break; +#if (CLR_2_0 || CLR_4_0) && !NETCF + case "XBOX": + isSupported = os.IsXbox; + break; + case "MACOSX": + isSupported = os.IsMacOSX; + break; +#endif default: isSupported = IsRuntimeSupported(platformName); diff --git a/src/NUnitCore/interfaces/OSPlatform.cs b/src/NUnitCore/interfaces/OSPlatform.cs index b80762ae..bfb681d2 100644 --- a/src/NUnitCore/interfaces/OSPlatform.cs +++ b/src/NUnitCore/interfaces/OSPlatform.cs @@ -206,6 +206,24 @@ namespace NUnit.Core get { return (int)platform == 3; } // PlatformID.WinCE not defined in .NET 1.0 } +#if (CLR_2_0 || CLR_4_0) && !NETCF + /// + /// Return true if the platform is Xbox + /// + public bool IsXbox + { + get { return platform == PlatformID.Xbox; } + } + + /// + /// Return true if the platform is MacOSX + /// + public bool IsMacOSX + { + get { return platform == PlatformID.MacOSX; } + } +#endif + /// /// Return true if the platform is Windows 95 /// diff --git a/src/NUnitCore/tests/PlatformDetectionTests.cs b/src/NUnitCore/tests/PlatformDetectionTests.cs index 35cf9544..57337c35 100644 --- a/src/NUnitCore/tests/PlatformDetectionTests.cs +++ b/src/NUnitCore/tests/PlatformDetectionTests.cs @@ -199,6 +199,24 @@ namespace NUnit.Core.Tests "UNIX,Linux"); } +#if (CLR_2_0 || CLR_4_0) && !NETCF + [Test] + public void DetectXbox() + { + CheckOSPlatforms( + new OSPlatform(PlatformID.Xbox, new Version(0, 0)), + "Xbox"); + } + + [Test] + public void DetectMacOSX() + { + CheckOSPlatforms( + new OSPlatform(PlatformID.MacOSX, new Version(0, 0)), + "MacOSX"); + } +#endif + [Test] public void DetectNet10() {