Add force change database logic (#519)

* add logic to close connections if changing fails

* added logic to close connections and reopen that fail to change (azure)

* expose connection map in connection info, change while to foreach

* removed unneeded code

* reworked logic to not depend on thrown errors

* added tests
This commit is contained in:
Anthony Dresser
2017-10-25 10:54:17 -07:00
committed by GitHub
parent f80fd8a458
commit 399b03cbd1
3 changed files with 194 additions and 13 deletions

View File

@@ -194,8 +194,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
public class TestSqlConnection : DbConnection
{
private string _database;
private ConnectionState _state;
internal TestSqlConnection(TestResultSet[] data)
public TestSqlConnection()
{
}
public TestSqlConnection(TestResultSet[] data)
{
Data = data;
}
@@ -227,7 +233,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
get { return _database; }
}
public override ConnectionState State { get; }
public override ConnectionState State
{
get { return _state; }
}
public override string DataSource { get; }
public override string ServerVersion { get; }
@@ -238,7 +248,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
public override void ChangeDatabase(string databaseName)
{
// No Op
_database = databaseName;
}
/// <summary>
@@ -249,6 +259,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{
this._database = database;
}
public void SetState(ConnectionState state)
{
this._state = state;
}
}
/// <summary>