* all net5 * var * SA1310 * SA1310 * allow 1031 * SA1805 * fix SA1642 * remove unused code * allow sa1405 * isempty * fix CA1714 * fix CA1806 * remove always false if * fix format * fix CA1062 * allow SA0001 * fix CA1062 * allow ca1034 and temp allow ca1835 * fix 16XX doc related warnings * elm SA16XX * elm SA16XX * fix CA2213 * revert to pass all test * move unclear rule to ruleset * follow up of moving ruleset * remove this * fix test flaky
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Runtime.InteropServices;
|
|
using Xunit;
|
|
|
|
namespace k8s.Tests
|
|
{
|
|
public class OperatingSystemDependentFactAttribute : FactAttribute
|
|
{
|
|
public OperatingSystems Include { get; set; } = OperatingSystems.Linux | OperatingSystems.Windows | OperatingSystems.OSX;
|
|
public OperatingSystems Exclude { get; set; }
|
|
|
|
public override string Skip
|
|
{
|
|
get => IsOS(Include) && !IsOS(Exclude) ? null : "Not compatible with current OS";
|
|
set { }
|
|
}
|
|
|
|
private bool IsOS(OperatingSystems operatingSystems)
|
|
{
|
|
if (operatingSystems.HasFlag(OperatingSystems.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (operatingSystems.HasFlag(OperatingSystems.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (operatingSystems.HasFlag(OperatingSystems.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|