private static string GetPlatformConditionFromTestPlatform(Xunit.TestPlatforms platform) { List <string> platformCheckConditions = new(); if (platform.HasFlag(Xunit.TestPlatforms.Windows)) { platformCheckConditions.Add("global::System.OperatingSystem.IsWindows()"); } if (platform.HasFlag(Xunit.TestPlatforms.Linux)) { platformCheckConditions.Add("global::System.OperatingSystem.IsLinux()"); } if (platform.HasFlag(Xunit.TestPlatforms.OSX)) { platformCheckConditions.Add("global::System.OperatingSystem.IsMacOS()"); } if (platform.HasFlag(Xunit.TestPlatforms.illumos)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsOSPlatform(""illumos"")"); } if (platform.HasFlag(Xunit.TestPlatforms.Solaris)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsOSPlatform(""Solaris"")"); } if (platform.HasFlag(Xunit.TestPlatforms.Android)) { platformCheckConditions.Add("global::System.OperatingSystem.IsAndroid()"); } if (platform.HasFlag(Xunit.TestPlatforms.iOS)) { platformCheckConditions.Add("(global::System.OperatingSystem.IsIOS() && !global::System.OperatingSystem.IsMacCatalyst())"); } if (platform.HasFlag(Xunit.TestPlatforms.tvOS)) { platformCheckConditions.Add("global::System.OperatingSystem.IsTvOS()"); } if (platform.HasFlag(Xunit.TestPlatforms.MacCatalyst)) { platformCheckConditions.Add("global::System.OperatingSystem.IsMacCatalyst()"); } if (platform.HasFlag(Xunit.TestPlatforms.Browser)) { platformCheckConditions.Add("global::System.OperatingSystem.IsBrowser()"); } if (platform.HasFlag(Xunit.TestPlatforms.FreeBSD)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsFreeBSD()"); } if (platform.HasFlag(Xunit.TestPlatforms.NetBSD)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsOSPlatform(""NetBSD"")"); } return(string.Join(" || ", platformCheckConditions)); }
public ConditionalTest(ITestInfo innerTest, Xunit.TestPlatforms platform) : this(innerTest, GetPlatformConditionFromTestPlatform(platform)) { }