diff --git a/TUnit.Engine.Tests/EnvironmentVariables.cs b/TUnit.Engine.Tests/EnvironmentVariables.cs new file mode 100644 index 0000000000..ffc6fde52d --- /dev/null +++ b/TUnit.Engine.Tests/EnvironmentVariables.cs @@ -0,0 +1,8 @@ +namespace TUnit.Engine.Tests; + +public class EnvironmentVariables +{ + public static readonly string? NetVersion = Environment.GetEnvironmentVariable("NET_VERSION"); + + public static readonly bool IsNet472 = NetVersion == "net472"; +} \ No newline at end of file diff --git a/TUnit.Engine.Tests/InvokableTestBase.cs b/TUnit.Engine.Tests/InvokableTestBase.cs index f5404e65ba..036fed6e3b 100644 --- a/TUnit.Engine.Tests/InvokableTestBase.cs +++ b/TUnit.Engine.Tests/InvokableTestBase.cs @@ -21,7 +21,7 @@ protected async Task RunTestsWithFilter(string filter, { await RunWithoutAot(filter, assertions, runOptions, assertionExpression); - if (Environment.GetEnvironmentVariable("NET_VERSION") == "net472") + if (EnvironmentVariables.IsNet472) { return; } diff --git a/TUnit.Pipeline/EnvironmentVariables.cs b/TUnit.Pipeline/EnvironmentVariables.cs new file mode 100644 index 0000000000..d62ada67b4 --- /dev/null +++ b/TUnit.Pipeline/EnvironmentVariables.cs @@ -0,0 +1,8 @@ +namespace TUnit.Pipeline; + +public class EnvironmentVariables +{ + public static readonly string? NetVersion = Environment.GetEnvironmentVariable("NET_VERSION"); + + public static readonly bool IsNet472 = NetVersion == "net472"; +} \ No newline at end of file diff --git a/TUnit.Pipeline/Modules/PublishAOTModule.cs b/TUnit.Pipeline/Modules/PublishAOTModule.cs index d589b2cbfb..f8bb57f084 100644 --- a/TUnit.Pipeline/Modules/PublishAOTModule.cs +++ b/TUnit.Pipeline/Modules/PublishAOTModule.cs @@ -15,7 +15,7 @@ public class PublishAOTModule : Module protected override Task ShouldSkip(IPipelineContext context) { - return Task.FromResult(Environment.GetEnvironmentVariable("NET_VERSION") == "net472"); + return Task.FromResult(EnvironmentVariables.IsNet472); } protected override async Task ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken) diff --git a/TUnit.Pipeline/Modules/PublishSingleFileModule.cs b/TUnit.Pipeline/Modules/PublishSingleFileModule.cs index ac3a4d0025..27f18b4eb7 100644 --- a/TUnit.Pipeline/Modules/PublishSingleFileModule.cs +++ b/TUnit.Pipeline/Modules/PublishSingleFileModule.cs @@ -17,7 +17,7 @@ public class PublishSingleFileModule : Module protected override Task ShouldSkip(IPipelineContext context) { - return Task.FromResult(Environment.GetEnvironmentVariable("NET_VERSION") == "net472"); + return Task.FromResult(EnvironmentVariables.IsNet472); } protected override async Task ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken) diff --git a/TUnit.Pipeline/Modules/TestNugetPackageModule.cs b/TUnit.Pipeline/Modules/TestNugetPackageModule.cs index 9fed7ad0c7..530ec3c943 100644 --- a/TUnit.Pipeline/Modules/TestNugetPackageModule.cs +++ b/TUnit.Pipeline/Modules/TestNugetPackageModule.cs @@ -18,7 +18,7 @@ public class TestNugetPackageModule : Module public TestNugetPackageModule() { - if (Environment.GetEnvironmentVariable("NET_VERSION") == "net472") + if (EnvironmentVariables.IsNet472) { _frameworks.Add("net472"); }