diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/FileUtils.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/FileUtils.cs index da44ccb4..02e78ca0 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/FileUtils.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/FileUtils.cs @@ -4,6 +4,7 @@ // using System; +using System.IO; using System.Runtime.InteropServices; namespace Microsoft.SqlTools.ServiceLayer.Test.Common @@ -53,17 +54,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common get { string testServerFileName = "testServerNames.json"; + return Path.Combine(TestServerNamesDefaultDirectory, testServerFileName); + } + } + + public static string TestServerNamesDefaultDirectory + { + get + { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return Environment.GetEnvironmentVariable("APPDATA") + @"\\" + testServerFileName; + return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - return Environment.GetEnvironmentVariable("HOME") + @"/" + testServerFileName; + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); } else { - return Environment.GetEnvironmentVariable("HOME") + @"/" + testServerFileName; + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); } } } diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConfigPersistenceHelper.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConfigPersistenceHelper.cs index a1b89f46..0e7106e0 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConfigPersistenceHelper.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConfigPersistenceHelper.cs @@ -152,11 +152,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common if (File.Exists(DefaultSettingFileName)) { settingsFileName = DefaultSettingFileName; - Console.WriteLine(DefaultSettingFileName + " SQL connection instances are not configured. Will try to get connections from VS code settings.json"); } else { //If the SQL connection settings is not set use the VS code one + Console.WriteLine(DefaultSettingFileName + " SQL connection instances are not configured. Will try to get connections from VS code settings.json"); settingsFileName = FileUtils.VsCodeSettingsFileName; } }