diff options
Diffstat (limited to '')
| -rw-r--r-- | src/test/burn/WixTestTools/RuntimeFactAttribute.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs index f73c87a2..573a9de2 100644 --- a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs +++ b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs | |||
| @@ -5,6 +5,7 @@ namespace WixTestTools | |||
| 5 | using System; | 5 | using System; |
| 6 | using System.Security.Principal; | 6 | using System.Security.Principal; |
| 7 | using WixInternal.TestSupport.XunitExtensions; | 7 | using WixInternal.TestSupport.XunitExtensions; |
| 8 | using System.Runtime.InteropServices; | ||
| 8 | 9 | ||
| 9 | public class RuntimeFactAttribute : SkippableFactAttribute | 10 | public class RuntimeFactAttribute : SkippableFactAttribute |
| 10 | { | 11 | { |
| @@ -12,6 +13,16 @@ namespace WixTestTools | |||
| 12 | 13 | ||
| 13 | public static bool RuntimeTestsEnabled { get; } | 14 | public static bool RuntimeTestsEnabled { get; } |
| 14 | public static bool RunningAsAdministrator { get; } | 15 | public static bool RunningAsAdministrator { get; } |
| 16 | public static bool RunningOnWindowsServer { get; } | ||
| 17 | |||
| 18 | [DllImport("shlwapi.dll", SetLastError = true, EntryPoint = "#437")] | ||
| 19 | private static extern bool IsOS(int os); | ||
| 20 | private static bool IsWindowsServer() | ||
| 21 | { | ||
| 22 | const int OS_ANYSERVER = 29; | ||
| 23 | return IsOS(OS_ANYSERVER); | ||
| 24 | } | ||
| 25 | |||
| 15 | 26 | ||
| 16 | static RuntimeFactAttribute() | 27 | static RuntimeFactAttribute() |
| 17 | { | 28 | { |
| @@ -21,6 +32,25 @@ namespace WixTestTools | |||
| 21 | 32 | ||
| 22 | var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName); | 33 | var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName); |
| 23 | RuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled; | 34 | RuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled; |
| 35 | |||
| 36 | RunningOnWindowsServer = IsWindowsServer(); | ||
| 37 | } | ||
| 38 | |||
| 39 | private bool _RequireWindowsServer; | ||
| 40 | public bool RequireWindowsServer | ||
| 41 | { | ||
| 42 | get | ||
| 43 | { | ||
| 44 | return _RequireWindowsServer; | ||
| 45 | } | ||
| 46 | set | ||
| 47 | { | ||
| 48 | _RequireWindowsServer = value; | ||
| 49 | if (_RequireWindowsServer && !RunningOnWindowsServer) | ||
| 50 | { | ||
| 51 | this.Skip = $"These tests are only run on Windows Server"; | ||
| 52 | } | ||
| 53 | } | ||
| 24 | } | 54 | } |
| 25 | 55 | ||
| 26 | public RuntimeFactAttribute() | 56 | public RuntimeFactAttribute() |
