IsPlatformSupported() public méthode

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
Résultat bool
 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"));
 }
        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));
        }
Exemple #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));
        }
        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);
                }
            }
        }
        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
        }
        public void SpecifyingNetCoreWithoutVersioningSucceeds()
        {
            PlatformHelper platformHelper = new PlatformHelper();
            bool           isNetCore;

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

            Assert.Throws <PlatformNotSupportedException>(() => platformHelper.IsPlatformSupported(netcoreRuntime));
        }
Exemple #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));
        }
Exemple #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));
        }