mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Perf Test fixing bugs and Update command (#155)
* Fixed some bugs caused by rafactoring * Verifying a test db is created before running the tests
This commit is contained in:
@@ -11,27 +11,55 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts
|
||||
{
|
||||
public class Scripts
|
||||
{
|
||||
|
||||
public const string SimpleQuery = "SELECT * FROM sys.all_columns";
|
||||
public const string MasterBasicQuery = "SELECT * FROM sys.all_columns"; //basic queries should return at least 10000 rows
|
||||
|
||||
public const string DelayQuery = "WAITFOR DELAY '00:01:00'";
|
||||
|
||||
private static readonly Lazy<string> ComplexQueryInstance = new Lazy<string>(() =>
|
||||
public const string TestDbSimpleSelectQuery = "SELECT * FROM [Person].[Address]";
|
||||
|
||||
public const string SelectQuery = "SELECT * FROM ";
|
||||
|
||||
public static string CreateDatabaseObjectsQuery { get { return CreateDatabaseObjectsQueryInstance.Value; } }
|
||||
|
||||
public static string CreateDatabaseQuery { get { return CreateDatabaseQueryInstance.Value; } }
|
||||
|
||||
public static string TestDbComplexSelectQueries { get { return TestDbSelectQueriesInstance.Value; } }
|
||||
|
||||
private static readonly Lazy<string> CreateDatabaseObjectsQueryInstance = new Lazy<string>(() =>
|
||||
{
|
||||
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.CreateTestDatabaseObjects.sql");
|
||||
});
|
||||
|
||||
private static readonly Lazy<string> CreateDatabaseQueryInstance = new Lazy<string>(() =>
|
||||
{
|
||||
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.CreateTestDatabase.sql");
|
||||
});
|
||||
|
||||
private static readonly Lazy<string> TestDbSelectQueriesInstance = new Lazy<string>(() =>
|
||||
{
|
||||
return GetScriptFileContent("Microsoft.SqlTools.ServiceLayer.TestDriver.Scripts.TestDbTableQueries.sql");
|
||||
});
|
||||
|
||||
private static string GetScriptFileContent(string fileName)
|
||||
{
|
||||
string fileContent = string.Empty;
|
||||
try
|
||||
{
|
||||
string assemblyLocation = typeof(Scripts).GetTypeInfo().Assembly.Location;
|
||||
string folderName = Path.GetDirectoryName(assemblyLocation);
|
||||
string filePath = Path.Combine(folderName, "Scripts/AdventureWorks.sql");
|
||||
return File.ReadAllText(filePath);
|
||||
using (Stream stream = typeof(Scripts).GetTypeInfo().Assembly.GetManifestResourceStream(fileName))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
fileContent = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to load the sql script. error: {ex.Message}");
|
||||
return string.Empty;
|
||||
}
|
||||
});
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
public static string ComplexQuery { get { return ComplexQueryInstance.Value; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user