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_IncludeAndExclude() { PlatformAttribute attr = new PlatformAttribute("Win2K,WinXP,NT4"); attr.Exclude = "Mono"; Assert.IsFalse(win95Helper.IsPlatformSupported(attr)); Assert.AreEqual("Only supported on Win2K,WinXP,NT4", win95Helper.Reason); Assert.IsTrue(winXPHelper.IsPlatformSupported(attr)); attr.Exclude = "Net"; Assert.IsFalse(win95Helper.IsPlatformSupported(attr)); Assert.AreEqual("Only supported on Win2K,WinXP,NT4", win95Helper.Reason); Assert.IsFalse(winXPHelper.IsPlatformSupported(attr)); Assert.AreEqual("Not supported on Net", winXPHelper.Reason); }
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)); }
public void TranslateMixedPlatformAndOSPlatformAttributes() { var supported1 = new SupportedOSPlatformAttribute("Windows"); var supported2 = new SupportedOSPlatformAttribute("Windows10"); var sourcePlatform = new PlatformAttribute("Win"); var sourceAttributes = new object[] { supported1, supported2, sourcePlatform }; object[] attributes = OSPlatformTranslator.Translate(sourceAttributes).ToArray(); Assert.That(attributes, Has.Length.EqualTo(1)); Assert.That(attributes[0], Is.InstanceOf <PlatformAttribute>()); var platform = (PlatformAttribute)attributes[0]; Assert.That(platform.Include, Is.EqualTo("Win,Windows10"), nameof(platform.Include)); Assert.That(platform.Exclude, Is.Null, nameof(platform.Exclude)); }
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 }
/// <summary> /// Tests to determine if the current platform is supported /// based on a platform attribute. /// </summary> /// <param name="platformAttribute">The attribute to examine</param> /// <returns></returns> public bool IsPlatformSupported( PlatformAttribute platformAttribute ) { string include = platformAttribute.Include; string exclude = platformAttribute.Exclude; try { if (include != null && !IsPlatformSupported(include)) { reason = string.Format("Only supported on {0}", include); return false; } if (exclude != null && IsPlatformSupported(exclude)) { reason = string.Format("Not supported on {0}", exclude); return false; } } catch (Exception ex) { reason = ex.Message; return false; } return true; }
public void PlatformAttribute_InvalidPlatform() { PlatformAttribute attr = new PlatformAttribute( "Net-1.0,Net11,Mono" ); Assert.IsFalse( winXPHelper.IsPlatformSupported( attr ) ); Assert.That( winXPHelper.Reason, Is.StringStarting("Invalid platform name")); Assert.That( winXPHelper.Reason, Is.StringContaining("Net11")); }
public void PlatformAttribute_IncludeAndExclude() { PlatformAttribute attr = new PlatformAttribute( "Win2K,WinXP,NT4" ); attr.Exclude = "Mono"; Assert.IsFalse( win95Helper.IsPlatformSupported( attr ) ); Assert.AreEqual( "Only supported on Win2K,WinXP,NT4", win95Helper.Reason ); Assert.IsTrue( winXPHelper.IsPlatformSupported( attr ) ); attr.Exclude = "Net"; Assert.IsFalse( win95Helper.IsPlatformSupported( attr ) ); Assert.AreEqual( "Only supported on Win2K,WinXP,NT4", win95Helper.Reason ); Assert.IsFalse( winXPHelper.IsPlatformSupported( attr ) ); Assert.AreEqual( "Not supported on Net", winXPHelper.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 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 }
/// <summary> /// Tests to determine if the current platform is supported /// based on a platform attribute. /// </summary> /// <param name="platformAttribute">The attribute to examine</param> /// <returns></returns> public bool IsPlatformSupported( PlatformAttribute platformAttribute ) { string include = platformAttribute.Include; string exclude = platformAttribute.Exclude; return IsPlatformSupported( include, exclude ); }
private async Task <Models.Platform> GetPlatform(PlatformAttribute platformAttribute, ValueBindingContext context) { PlatformsClient platformsClient = new PlatformsClient(platformAttribute.ServiceUrlEnvironmentVariable, _httpClientFactory); return(await platformsClient.GetPlatform(platformAttribute.PlatformId)); }