diff --git a/Directory.Packages.props b/Directory.Packages.props index d3f0cd18..16955bbe 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -25,7 +25,7 @@ - + diff --git a/test/AdaptiveRemote.App.Tests/Services/ProgrammaticSettings/PersistSettingsTests.cs b/test/AdaptiveRemote.App.Tests/Services/ProgrammaticSettings/PersistSettingsTests.cs index 98fc4ba0..be42e1cd 100644 --- a/test/AdaptiveRemote.App.Tests/Services/ProgrammaticSettings/PersistSettingsTests.cs +++ b/test/AdaptiveRemote.App.Tests/Services/ProgrammaticSettings/PersistSettingsTests.cs @@ -5,8 +5,24 @@ namespace AdaptiveRemote.Services.ProgrammaticSettings; [TestClass] public class PersistSettingsTests { - private static readonly string InputSettingsPath = Path.Combine("%LocalAppData%", "path", "to", "settings.ini"); - private static readonly string ResolvedSettingsPath = Environment.ExpandEnvironmentVariables(InputSettingsPath); + private const string TestSettingsDirEnvVar = "AR_TEST_SETTINGS_DIR"; + private static readonly string InputSettingsPath = Path.Combine($"%{TestSettingsDirEnvVar}%", "path", "to", "settings.ini"); + private static string ResolvedSettingsPath => Environment.ExpandEnvironmentVariables(InputSettingsPath); + + private static string? _previousTestSettingsDirValue; + + [ClassInitialize] + public static void ClassInitialize(TestContext context) + { + _previousTestSettingsDirValue = Environment.GetEnvironmentVariable(TestSettingsDirEnvVar); + Environment.SetEnvironmentVariable(TestSettingsDirEnvVar, Path.Combine(Path.GetTempPath(), "AdaptiveRemoteTests")); + } + + [ClassCleanup] + public static void ClassCleanup() + { + Environment.SetEnvironmentVariable(TestSettingsDirEnvVar, _previousTestSettingsDirValue); + } private readonly MockLogger MockLogger = new(); private readonly MockFileSystem MockFileSystem = new(); diff --git a/test/AdaptiveRemote.EndToEndTests.Host.Wpf/AdaptiveRemote.EndToEndTests.Host.Wpf.csproj b/test/AdaptiveRemote.EndToEndTests.Host.Wpf/AdaptiveRemote.EndToEndTests.Host.Wpf.csproj index 808f3c5d..f80a6b55 100644 --- a/test/AdaptiveRemote.EndToEndTests.Host.Wpf/AdaptiveRemote.EndToEndTests.Host.Wpf.csproj +++ b/test/AdaptiveRemote.EndToEndTests.Host.Wpf/AdaptiveRemote.EndToEndTests.Host.Wpf.csproj @@ -6,6 +6,7 @@ enable enable Exe + true diff --git a/test/AdaptiveRemote.EndtoEndTests.Host.Console/AdaptiveRemote.EndToEndTests.Host.Console.csproj b/test/AdaptiveRemote.EndtoEndTests.Host.Console/AdaptiveRemote.EndToEndTests.Host.Console.csproj index b7ccd9b2..6e2f5b6e 100644 --- a/test/AdaptiveRemote.EndtoEndTests.Host.Console/AdaptiveRemote.EndToEndTests.Host.Console.csproj +++ b/test/AdaptiveRemote.EndtoEndTests.Host.Console/AdaptiveRemote.EndToEndTests.Host.Console.csproj @@ -6,6 +6,7 @@ enable enable Exe + true