Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.PerfTests/Tests/SaveResultsTests.cs
Alex Ma d3c28d358f Revert change to nunit and restore xunit (#2249)
* Revert "Added new test framework (test) (#2247)"

This reverts commit b2120269a7.

* Added assert Fail as a test
2023-09-22 13:07:48 -07:00

62 lines
2.6 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#nullable disable
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.PerfTests
{
public class SaveResultsTests
{
[Fact]
public async Task TestSaveResultsToCsvTest()
{
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
{
TestServerType serverType = TestServerType.OnPrem;
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{
const string query = Scripts.MasterBasicQuery;
// Execute a query
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
await testService.CalculateRunTime(() => testService.SaveAsCsv(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), timer);
await testService.Disconnect(queryTempFile.FilePath);
}
});
}
[Fact]
public async Task TestSaveResultsToJsonTest()
{
await TestServiceDriverProvider.RunTestIterations(async (timer) =>
{
TestServerType serverType = TestServerType.OnPrem;
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
using (SelfCleaningTempFile outputTempFile = new SelfCleaningTempFile())
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{
const string query = Scripts.MasterBasicQuery;
// Execute a query
await testService.ConnectForQuery(serverType, query, queryTempFile.FilePath, SqlTestDb.MasterDatabaseName);
await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, query);
await testService.CalculateRunTime(() => testService.SaveAsJson(queryTempFile.FilePath, outputTempFile.FilePath, 0, 0), timer);
await testService.Disconnect(queryTempFile.FilePath);
}
});
}
}
}