IsPlatformSupported() public method

Tests to determine if the current platform is supported based on a platform attribute.
public IsPlatformSupported ( PlatformAttribute platformAttribute ) : bool
platformAttribute PlatformAttribute The attribute to examine
return bool
Exemplo n.º 1
0
 public void DetectExactVersion()
 {
     Assert.IsTrue(winXPHelper.IsPlatformSupported("net-1.1.4322"));
     Assert.IsTrue(winXPHelper.IsPlatformSupported("net-1.1.4322.0"));
     Assert.IsFalse(winXPHelper.IsPlatformSupported("net-1.1.4323.0"));
     Assert.IsFalse(winXPHelper.IsPlatformSupported("net-1.1.4322.1"));
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        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 ASYNC
            // For .NET 4.0 and 4.5, we can check further
            Assert.That(is64BitProcess, Is.EqualTo(Environment.Is64BitProcess));
#endif
        }
Exemplo n.º 6
0
        public void SpecifyingNetCoreWithoutVersioningSucceeds()
        {
            PlatformHelper platformHelper = new PlatformHelper();
            bool           isNetCore;

#if NETCOREAPP
            isNetCore = true;
#else
            isNetCore = false;
#endif
            Assert.AreEqual(isNetCore, platformHelper.IsPlatformSupported("netcore"));
        }
Exemplo n.º 7
0
		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 );
			}
		}
Exemplo n.º 8
0
 public void ArrayOfPlatforms()
 {
     string[] platforms = new string[] { "NT4", "Win2K", "WinXP" };
     Assert.IsTrue(winXPHelper.IsPlatformSupported(platforms));
     Assert.IsFalse(win95Helper.IsPlatformSupported(platforms));
 }
Exemplo n.º 9
0
        /// <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;
        }
Exemplo n.º 10
0
        public void SpecifyingNetCoreVersioningThrowsPlatformException(string netcoreRuntime)
        {
            PlatformHelper platformHelper = new PlatformHelper();

            Assert.Throws <PlatformNotSupportedException>(() => platformHelper.IsPlatformSupported(netcoreRuntime));
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        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 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));
        }