diff --git a/tests/ConfigR.Tests.Acceptance.Roslyn.CSharp/LocalConfigurationFeature.cs b/tests/ConfigR.Tests.Acceptance.Roslyn.CSharp/LocalConfigurationFeature.cs index 3860e37..9426a24 100644 --- a/tests/ConfigR.Tests.Acceptance.Roslyn.CSharp/LocalConfigurationFeature.cs +++ b/tests/ConfigR.Tests.Acceptance.Roslyn.CSharp/LocalConfigurationFeature.cs @@ -5,6 +5,7 @@ namespace ConfigR.Tests.Acceptance.Roslyn.CSharp { using System; + using System.IO; using ConfigR.Tests.Acceptance.Roslyn.CSharp.Support; using FluentAssertions; using Xbehave; @@ -69,5 +70,22 @@ public static void ScriptFailsToExecute(Exception exception) "And the exception message is 'Boo!'" .f(() => exception.Message.Should().Be("Boo!")); } + + [Scenario] + public static void ConfigurationFileIsNull(Exception exception) + { + "Given the app domain configuration file is null" + .f(c => AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", null)) + .Teardown(() => AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", Path.GetFileName(ConfigFile.GetDefaultPath()))); + + "When I load the config file" + .f(async () => exception = await Record.ExceptionAsync(async () => await new Config().UseRoslynCSharpLoader().Load())); + + "Then an invalid operation exception is thrown" + .f(() => exception.Should().NotBeNull()); + + "And the exception message tells us that the app domain config file is null" + .f(() => exception.Message.Should().Be("AppDomain.CurrentDomain.SetupInformation.ConfigurationFile is null.")); + } } }