some bug fixes in pref tests

This commit is contained in:
Leila Lali
2016-11-11 10:07:55 -08:00
parent 18bf76caed
commit 80a847ff4f
5 changed files with 80 additions and 52 deletions

View File

@@ -7,6 +7,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
{
public class TestResult
{
public string ElapsedTime { get; set; }
public double ElapsedTime { get; set; }
}
}

View File

@@ -14,7 +14,19 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
/// </summary>
public class TestTimer
{
private static string ResultFolder = Environment.GetEnvironmentVariable("ResultFolder");
private static string resultFolder = InitResultFolder();
private static string InitResultFolder()
{
string resultFodler = Environment.GetEnvironmentVariable("ResultFolder");
if (string.IsNullOrEmpty(resultFodler))
{
string assemblyLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
resultFodler = Path.GetDirectoryName(assemblyLocation);
}
return resultFodler;
}
public TestTimer()
{
@@ -38,10 +50,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Test Name: {0} Run time in milliSeconds: {1}", testName, TotalMilliSeconds));
Console.ForegroundColor = currentColor;
string resultContent = Newtonsoft.Json.JsonConvert.SerializeObject(new TestResult { ElapsedTime = TotalMilliSeconds.ToString() });
string resultContent = Newtonsoft.Json.JsonConvert.SerializeObject(new TestResult { ElapsedTime = TotalMilliSeconds });
string fileName = testName + ".json";
string resultFilePath = string.IsNullOrEmpty(ResultFolder) ? fileName : Path.Combine(ResultFolder, fileName);
string resultFilePath = string.IsNullOrEmpty(resultFolder) ? fileName : Path.Combine(resultFolder, fileName);
File.WriteAllText(resultFilePath, resultContent);
Console.WriteLine("Result file: " + resultFilePath);
}
public double TotalMilliSeconds