mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 17:24:14 -05:00
Support connecting with a connection string (#334)
- Add support for connecting with a connection string by passing it as one of the connection parameters - If a connection string is present, it will override any other parameters that are present
This commit is contained in:
@@ -44,12 +44,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
GetTestConnectionDetails());
|
||||
}
|
||||
|
||||
public static ConnectParams GetTestConnectionParams()
|
||||
public static ConnectParams GetTestConnectionParams(bool useConnectionString = false)
|
||||
{
|
||||
return new ConnectParams()
|
||||
{
|
||||
OwnerUri = ScriptUri,
|
||||
Connection = GetTestConnectionDetails()
|
||||
Connection = GetTestConnectionDetails(useConnectionString)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
ServerEdition = "Developer Edition",
|
||||
ServerLevel = ""
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a test sql connection factory instance
|
||||
/// </summary>
|
||||
@@ -80,8 +80,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
/// <summary>
|
||||
/// Creates a test connection details object
|
||||
/// </summary>
|
||||
public static ConnectionDetails GetTestConnectionDetails()
|
||||
public static ConnectionDetails GetTestConnectionDetails(bool useConnectionString = false)
|
||||
{
|
||||
if (useConnectionString)
|
||||
{
|
||||
return new ConnectionDetails()
|
||||
{
|
||||
ConnectionString = "User ID=user;PWD=password;Database=databaseName;Server=serverName"
|
||||
};
|
||||
}
|
||||
|
||||
return new ConnectionDetails()
|
||||
{
|
||||
UserName = "user",
|
||||
@@ -214,9 +222,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
}
|
||||
|
||||
public override string ConnectionString { get; set; }
|
||||
public override string Database
|
||||
public override string Database
|
||||
{
|
||||
get { return _database; }
|
||||
get { return _database; }
|
||||
}
|
||||
|
||||
public override ConnectionState State { get; }
|
||||
@@ -233,13 +241,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
|
||||
// No Op
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test helper method to set the database value
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Test helper method to set the database value
|
||||
/// </summary>
|
||||
/// <param name="database"></param>
|
||||
public void SetDatabase(string database)
|
||||
{
|
||||
this._database = database;
|
||||
public void SetDatabase(string database)
|
||||
{
|
||||
this._database = database;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user