Added TestEnvironment

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-11-30 08:51:12 +01:00
parent 6ce8e55210
commit 85df7be7e8
2 changed files with 31 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ using Umbraco.Web;
using Umbraco.Web.Routing;
using Umbraco.Tests.Common.Builders;
using System.Runtime.InteropServices;
using Umbraco.Tests.Common.TestHelpers;
namespace Umbraco.Tests.Common
{
@@ -89,8 +90,23 @@ namespace Umbraco.Tests.Common
if (_ioHelper == null)
{
var hostingEnvironment = GetHostingEnvironment();
_ioHelper = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? new IOHelperLinux(hostingEnvironment)
: (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? (IIOHelper)new IOHelperOSX(hostingEnvironment) : new IOHelperWindows(hostingEnvironment));
if (TestEnvironment.IsWindows)
{
_ioHelper = new IOHelperWindows(hostingEnvironment);
}
else if (TestEnvironment.IsLinux)
{
_ioHelper = new IOHelperLinux(hostingEnvironment);
}
else if (TestEnvironment.IsOSX)
{
_ioHelper = new IOHelperOSX(hostingEnvironment);
}
else
{
throw new NotSupportedException("Unexpected OS");
}
}
return _ioHelper;
}

View File

@@ -0,0 +1,13 @@
using System.Runtime.InteropServices;
namespace Umbraco.Tests.Common.TestHelpers
{
public static class TestEnvironment
{
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
public static bool IsOSX => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}
}