internal static ConnectionSetting InitSetting() { try { string settingsFileContents = GetSettingFileContent(); ConnectionSetting setting = Newtonsoft.Json.JsonConvert.DeserializeObject <ConnectionSetting>(settingsFileContents); Console.WriteLine("Connection Settings loaded successfully"); return(setting); } catch (Exception ex) { Console.WriteLine("Failed to load the connection settings. error: " + ex.Message); return(new ConnectionSetting()); } }
/// <summary> /// Forces the InstanceManager to load/reload it's instance list /// </summary> internal void LoadInstanceSettings() { try { connectionProfilesCache = new Dictionary <string, InstanceInfo>(); IEnumerable <TestServerIdentity> testServers = TestConfigPersistenceHelper.InitTestServerNames(); ConnectionSetting settings = TestConfigPersistenceHelper.InitSetting(); if (settings == null) { Console.WriteLine("DBTestInstance not configured. Run 'dotnet run Microsoft.SqlTools.ServiceLayer.TestEnvConfig from the command line to configure"); } if (testServers != null && settings != null) { foreach (var serverIdentity in testServers) { var instance = settings != null?settings.GetConnectionProfile(serverIdentity.ProfileName, serverIdentity.ServerName) : null; if (instance.ServerType == TestServerType.None) { instance.ServerType = serverIdentity.ServerType; AddInstance(instance); } } } if (settings != null) { foreach (var instance in settings.Connections) { AddInstance(instance); } } } catch (Exception ex) { Assert.True(false, "Fail to load the SQL connection instances. error: " + ex.Message); } }