mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-19 09:35:36 -05:00
@@ -266,33 +266,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two strings and gives appropriate output
|
||||
/// </summary>
|
||||
/// <param name="actualContent">Actual string</param>
|
||||
/// <param name="baselineContent">Expected string</param>
|
||||
/// <remarks>Fails test if strings do not match; comparison is done using an InvariantCulture StringComparer</remarks>
|
||||
public static void CompareActualWithBaseline(string actualContent, string baselineContent)
|
||||
{
|
||||
|
||||
int _compareResult = string.Compare(actualContent, baselineContent, StringComparison.OrdinalIgnoreCase);
|
||||
if (_compareResult != 0)
|
||||
{
|
||||
Trace.WriteLine("Debug Info:");
|
||||
Trace.WriteLine("========BEGIN=EXPECTED========");
|
||||
Trace.WriteLine(baselineContent);
|
||||
Trace.WriteLine("=========END=EXPECTED=========");
|
||||
Trace.WriteLine("=========BEGIN=ACTUAL=========");
|
||||
Trace.WriteLine(actualContent);
|
||||
Trace.WriteLine("==========END=ACTUAL==========");
|
||||
Assert.True(false, string.Format("Comparison failed! (actualContent {0} baselineContent)", (_compareResult < 0 ? "<" : ">"))); //we already know it is not equal
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("Compare match! All is fine...");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the testscript with the provided name
|
||||
/// </summary>
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
uri = queryTempFile.FilePath;
|
||||
|
||||
ConnectionInfo connInfo = InitLiveConnectionInfo(serverType, databaseName, uri);
|
||||
ConnectionInfo connInfo = await InitLiveConnectionInfo(serverType, databaseName, uri);
|
||||
Query query = new Query(queryText, connInfo, new QueryExecutionSettings(), MemoryFileSystem.GetFileStreamFactory());
|
||||
query.Execute();
|
||||
await query.ExecutionTask;
|
||||
@@ -132,23 +132,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
return result;
|
||||
}
|
||||
|
||||
private ConnectionInfo InitLiveConnectionInfo(TestServerType serverType, string databaseName, string scriptFilePath)
|
||||
private async Task<ConnectionInfo> InitLiveConnectionInfo(TestServerType serverType, string databaseName, string scriptFilePath)
|
||||
{
|
||||
ConnectParams connectParams = ConnectionProfileService.GetConnectionParameters(serverType, databaseName);
|
||||
|
||||
string ownerUri = scriptFilePath;
|
||||
var connectionService = ConnectionService.Instance;
|
||||
var connectionResult = connectionService.Connect(new ConnectParams()
|
||||
var connectionResult = await connectionService.Connect(new ConnectParams()
|
||||
{
|
||||
OwnerUri = ownerUri,
|
||||
Connection = connectParams.Connection
|
||||
});
|
||||
|
||||
connectionResult.Wait();
|
||||
|
||||
ConnectionInfo connInfo = null;
|
||||
if(!string.IsNullOrEmpty(connectionResult.ErrorMessage))
|
||||
{
|
||||
throw new Exception($"Error creating live connection to {connectParams.Connection.ServerName} (Type={serverType}). Error: {connectionResult.ErrorMessage}");
|
||||
}
|
||||
ConnectionInfo? connInfo = null;
|
||||
connectionService.TryFindConnection(ownerUri, out connInfo);
|
||||
Assert.NotNull(connInfo);
|
||||
Assert.That(connInfo, Is.Not.Null, $"Could not find connection {ownerUri} when creating live connection");
|
||||
return connInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user