diff --git a/Recurly.Tests/BaseClientTest.cs b/Recurly.Tests/BaseClientTest.cs index 6b80ff0b..ca01cbef 100644 --- a/Recurly.Tests/BaseClientTest.cs +++ b/Recurly.Tests/BaseClientTest.cs @@ -138,10 +138,15 @@ public void WillThrowARecurlyErrorForUnknownErrors() [Fact] public void WillThrowAnApiErrorForUnknownErrorType() { + // Force RECURLY_STRICT_MODE for this test + Environment.SetEnvironmentVariable("RECURLY_STRICT_MODE", "TRUE"); + var client = MockClient.Build(UnknownTypeResponse()); // Instead of disabling strict mode, test with ArgumentException as proxy var exception = Assert.Throws(() => client.GetResource("benjamin", "param1", new DateTime(2020, 01, 01))); Assert.Matches("no valid exception class", exception.Message); + + Environment.SetEnvironmentVariable("RECURLY_STRICT_MODE", null); } [Fact] diff --git a/Recurly/Utils.cs b/Recurly/Utils.cs index dda939f8..2d0d0892 100644 --- a/Recurly/Utils.cs +++ b/Recurly/Utils.cs @@ -19,7 +19,7 @@ public static bool StrictMode { if (!strictMode.HasValue) { - strictMode = Environment.GetEnvironmentVariable("RECURLY_STRICT_MODE").ToUpper() == "TRUE"; + strictMode = Environment.GetEnvironmentVariable("RECURLY_STRICT_MODE")?.ToUpper() == "TRUE"; } } }