private void CheckPlatforms( PlatformHelper helper, string expectedPlatforms, string checkPlatforms ) { string[] expected = expectedPlatforms.Split( new char[] { ',' } ); string[] check = checkPlatforms.Split( new char[] { ',' } ); foreach( string testPlatform in check ) { bool shouldPass = false; foreach( string platform in expected ) if ( shouldPass = platform.ToLower() == testPlatform.ToLower() ) break; bool didPass = helper.IsPlatformSupported( testPlatform ); if ( shouldPass && !didPass ) Assert.Fail( "Failed to detect {0}", testPlatform ); else if ( didPass && !shouldPass ) Assert.Fail( "False positive on {0}", testPlatform ); else if ( !shouldPass && !didPass ) Assert.AreEqual( "Only supported on " + testPlatform, helper.Reason ); } }
/// <summary> /// Construct one or more TestMethods from a given MethodInfo, /// using available parameter data. /// </summary> /// <param name="method">The MethodInfo for which tests are to be constructed.</param> /// <param name="suite">The suite to which the tests will be added.</param> /// <returns>One or more TestMethods</returns> public IEnumerable<TestMethod> BuildFrom(MethodInfo method, Test suite) { TestMethod test = new NUnitTestCaseBuilder().BuildTestMethod(method, suite, GetParametersForTestCase(method)); #if !PORTABLE if (test.RunState != RunState.NotRunnable && test.RunState != RunState.Ignored) { PlatformHelper platformHelper = new PlatformHelper(); if (!platformHelper.IsPlatformSupported(this)) { test.RunState = RunState.Skipped; test.Properties.Add(PropertyNames.SkipReason, platformHelper.Reason); } } #endif yield return test; }
public void PlatformAttribute_OperatingSystemBitNess() { PlatformAttribute attr32 = new PlatformAttribute("32-Bit-OS"); PlatformAttribute attr64 = new PlatformAttribute("64-Bit-OS"); PlatformHelper helper = new PlatformHelper(); bool is64BitOS = Environment.Is64BitOperatingSystem; Assert.That(helper.IsPlatformSupported(attr32), Is.Not.EqualTo(is64BitOS)); Assert.That(helper.IsPlatformSupported(attr64), Is.EqualTo(is64BitOS)); }
public void PlatformAttribute_ProcessBitNess() { PlatformAttribute attr32 = new PlatformAttribute("32-Bit"); PlatformAttribute attr64 = new PlatformAttribute("64-Bit"); PlatformHelper helper = new PlatformHelper(); // This test verifies that the two labels are known, // do not cause an error and return consistent results. bool is32BitProcess = helper.IsPlatformSupported(attr32); bool is64BitProcess = helper.IsPlatformSupported(attr64); Assert.False(is32BitProcess & is64BitProcess, "Process cannot be both 32 and 64 bit"); #if NET_4_0 || NET_4_5 || PORTABLE // For .NET 4.0 and 4.5, we can check further Assert.That(is64BitProcess, Is.EqualTo(Environment.Is64BitProcess)); #endif }
public void SpecifyingNetCoreVersioningThrowsPlatformException(string netcoreRuntime) { PlatformHelper platformHelper = new PlatformHelper(); Assert.Throws <PlatformNotSupportedException>(() => platformHelper.IsPlatformSupported(netcoreRuntime)); }
public void PlatformAttribute_OperatingSystemBitNess() { PlatformAttribute attr32 = new PlatformAttribute("32-Bit-OS"); PlatformAttribute attr64 = new PlatformAttribute("64-Bit-OS"); PlatformHelper helper = new PlatformHelper(); // This test verifies that the two labels are known, // do not cause an error and return consistent results. bool is32Bit = helper.IsPlatformSupported(attr32); bool is64Bit = helper.IsPlatformSupported(attr64); Assert.False(is32Bit & is64Bit, "Cannot be both 32 bit and 64 bit"); Assert.That(is64Bit, Is.EqualTo(Environment.Is64BitProcess)); }