Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 442de47

Browse files
committed
Register License Key in env variable if exists
1 parent 0b6e613 commit 442de47

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

tests/ServiceStack.Text.Tests/LicenseUsageTests.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ public void SetUp()
2020
[TearDown]
2121
public void TearDown()
2222
{
23-
#if NETCORE
24-
Licensing.RegisterLicense(System.Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE"));
25-
#else
26-
Licensing.RegisterLicense(new AppSettings().GetString("servicestack:license"));
27-
#endif
23+
LicenseHelper.RegisterLicense();
2824
}
2925

3026
[Test]
@@ -87,11 +83,7 @@ public class RegisteredLicenseUsageTests : LicenseUsageTests
8783
[Test]
8884
public void Allows_serialization_of_21_types()
8985
{
90-
#if NETCORE
91-
Licensing.RegisterLicense(System.Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE"));
92-
#else
93-
Licensing.RegisterLicense(new AppSettings().GetString("servicestack:license"));
94-
#endif
86+
LicenseHelper.RegisterLicense();
9587

9688
Serialize20();
9789
Serialize20();
@@ -102,6 +94,22 @@ public void Allows_serialization_of_21_types()
10294
"{\"Id\":1}".FromJson<T21>();
10395
}
10496
}
97+
98+
public static class LicenseHelper
99+
{
100+
public static void RegisterLicense()
101+
{
102+
var envKey = System.Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE");
103+
if (envKey != null)
104+
{
105+
Licensing.RegisterLicense(envKey);
106+
}
107+
108+
#if !NETCORE
109+
Licensing.RegisterLicense(new AppSettings().GetString("servicestack:license"));
110+
#endif
111+
}
112+
}
105113

106114
class T01 { public int Id { get; set; } }
107115
class T02 { public int Id { get; set; } }

0 commit comments

Comments
 (0)