Fixing bug in GetOrOpenConnection (#234)

Fixes a bug where the GetOrOpenConnection method of the ConnectionService would throw if the connection didn't exist. It would yield a very unhelpful "key not found in collection" exception. The code has been updated to be much more helpful and fix the bug.
This commit is contained in:
Benjamin Russell
2017-02-17 17:21:47 -08:00
committed by GitHub
parent fda0005241
commit 4808a7df10
6 changed files with 76 additions and 10 deletions

View File

@@ -206,7 +206,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
public static ConnectionInfo CreateTestConnectionInfo(TestResultSet[] data, bool throwOnRead)
{
return new ConnectionInfo(CreateMockFactory(data, throwOnRead), OwnerUri, StandardConnectionDetails);
// Create a connection info and add the default connection to it
ISqlConnectionFactory factory = CreateMockFactory(data, throwOnRead);
ConnectionInfo ci = new ConnectionInfo(factory, OwnerUri, StandardConnectionDetails);
ci.ConnectionTypeToConnectionMap[ConnectionType.Default] = factory.CreateSqlConnection(null);
return ci;
}
public static ConnectionInfo CreateConnectedConnectionInfo(TestResultSet[] data, bool throwOnRead, string type = ConnectionType.Default)