If the test name file cannot be found just use the settings.json

This commit is contained in:
Leila Lali
2016-11-09 16:12:11 -08:00
parent 92420e734f
commit 18bf76caed
6 changed files with 81 additions and 18 deletions

View File

@@ -18,9 +18,18 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
public class PerformanceTests : TestBase
{
private static string ComplexQuery = File.ReadAllText("./Scripts/AdventureWorks.sql");
private static string ComplexQuery = LoadComplexScript();
private static string SimpleQuery = "SELECT * FROM sys.all_columns";
private static string LoadComplexScript()
{
string assemblyLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
string folderName = Path.GetDirectoryName(assemblyLocation);
string filePath = Path.Combine(folderName, "Scripts/AdventureWorks.sql");
return File.ReadAllText(filePath);
}
[Fact]
public async Task HoverTestOnPrem()
{
@@ -556,6 +565,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
TestTimer timer = new TestTimer();
T result = await testToRun();
timer.EndAndPrint(testName);
return result;
}
}

View File

@@ -183,12 +183,32 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
/// </summary>
protected async Task<ConnectParams> GetDatabaseConnectionAsync(TestServerType serverType)
{
ConnectionProfile connectionProfile = null;
TestServerIdentity serverIdentiry = ConnectionTestUtils.TestServers.FirstOrDefault(x => x.ServerType == serverType);
var connectionProfile = ConnectionTestUtils.Setting.GetConnentProfile(serverIdentiry.ProfileName, serverIdentiry.ServerName);
Credential credential = await ReadCredential(connectionProfile.formatCredentialId());
ConnectParams conenctParam = ConnectionTestUtils.CreateConnectParams(connectionProfile.ServerName, connectionProfile.Database,
connectionProfile.User, credential.Password);
return conenctParam;
if (serverIdentiry == null)
{
connectionProfile = ConnectionTestUtils.Setting.Connections.FirstOrDefault(x => x.ServerType == serverType);
}
else
{
connectionProfile = ConnectionTestUtils.Setting.GetConnentProfile(serverIdentiry.ProfileName, serverIdentiry.ServerName);
}
if (connectionProfile != null)
{
string password = connectionProfile.Password;
if (string.IsNullOrEmpty(password))
{
Credential credential = await ReadCredential(connectionProfile.formatCredentialId());
password = credential.Password;
}
ConnectParams conenctParam = ConnectionTestUtils.CreateConnectParams(connectionProfile.ServerName, connectionProfile.Database,
connectionProfile.User, password);
return conenctParam;
}
return null;
}
/// <summary>