Convert most tools service tests to nunit (#1037)

* Remove xunit dependency from testdriver

* swap expected/actual as needed

* Convert Test.Common to nunit

* port hosting unit tests to nunit

* port batchparser integration tests to nunit

* port testdriver.tests to nunit

* fix target to copy dependency

* port servicelayer unittests to nunit

* more unit test fixes

* port integration tests to nunit

* fix test method type

* try using latest windows build for PRs

* reduce test memory use
This commit is contained in:
David Shiflet
2020-08-05 13:43:14 -04:00
committed by GitHub
parent bf4911795f
commit 839acf67cd
205 changed files with 4146 additions and 4329 deletions

View File

@@ -11,7 +11,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -20,7 +20,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify default agent/alerts handlers
/// </summary>
[Fact]
[Test]
public async Task TestHandleAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -42,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify the default "create agent alert" request handler with valid parameters
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify the default "update agent alert" request handler with valid parameters
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleCreateAgentJobStepRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleUpdateAgentJobStepRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -71,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleDeleteAgentJobRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleDeleteAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleCreateAgentJobRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -43,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleUpdateAgentJobRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -66,7 +66,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleDeleteAgentJobRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleDeleteAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestAgentJobDefaultsRequest
/// </summary>
[Fact]
[Test]
public async Task TestAgentJobDefaultsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -8,7 +8,7 @@ using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -17,7 +17,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Test case for fetch notebook jobs Request Handler
/// </summary>
[Fact]
[Test]
public async Task TestHandleAgentNotebooksRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -40,16 +40,16 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Tests the create job helper function
/// </summary>
[Fact]
internal async Task TestAgentNotebookCreateHelper()
[Test]
public async Task TestAgentNotebookCreateHelper()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
AgentNotebookInfo notebook = AgentTestUtils.GetTestNotebookInfo("myTestNotebookJob" + Guid.NewGuid().ToString(), "master");
Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
notebook = AgentTestUtils.SetupNotebookJob(connectionResult).Result;
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
await AgentTestUtils.CleanupNotebookJob(connectionResult, notebook);
}
}
@@ -57,8 +57,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Tests the create job request handler with an invalid file path
/// </summary>
[Fact]
internal async Task TestHandleCreateAgentNotebookRequestWithInvalidTemplatePath()
[Test]
public async Task TestHandleCreateAgentNotebookRequestWithInvalidTemplatePath()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -75,15 +75,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
}, createNotebookContext.Object);
createNotebookContext.Verify(x => x.SendResult(It.Is<CreateAgentNotebookResult>(p => p.Success == false)));
Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
}
}
/// <summary>
/// creating a job with duplicate name
/// </summary>
[Fact]
internal async Task TestDuplicateJobCreation()
[Test]
public async Task TestDuplicateJobCreation()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -114,8 +114,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Tests the create notebook job handler
/// </summary>
[Fact]
internal async Task TestCreateAgentNotebookHandler()
[Test]
public async Task TestCreateAgentNotebookHandler()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -131,7 +131,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
TemplateFilePath = AgentTestUtils.CreateTemplateNotebookFile()
}, createNotebookContext.Object);
createNotebookContext.Verify(x => x.SendResult(It.Is<CreateAgentNotebookResult>(p => p.Success == true)));
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
var createdNotebook = AgentTestUtils.GetNotebook(connectionResult, notebook.Name);
await AgentTestUtils.CleanupNotebookJob(connectionResult, createdNotebook);
}
@@ -140,8 +140,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Tests the delete notebook job handler
/// </summary>
[Fact]
internal async Task TestDeleteAgentNotebookHandler()
[Test]
public async Task TestDeleteAgentNotebookHandler()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -150,7 +150,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
//creating a notebook job
AgentNotebookInfo notebook = AgentTestUtils.SetupNotebookJob(connectionResult).Result;
//verifying it's getting created
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
//deleting the notebook job
var deleteNotebookContext = new Mock<RequestContext<ResultStatus>>();
deleteNotebookContext.Setup(x => x.SendResult(It.IsAny<ResultStatus>())).Returns(Task.FromResult(new object()));
@@ -161,15 +161,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
}, deleteNotebookContext.Object);
deleteNotebookContext.Verify(x => x.SendResult(It.Is<ResultStatus>(p => p.Success == true)));
//verifying if the job is deleted
Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
}
}
/// <summary>
/// deleting a existing notebook job
/// </summary>
[Fact]
internal async Task TestDeleteNonExistentJob()
[Test]
public async Task TestDeleteNonExistentJob()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -193,8 +193,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// updating a non existing notebook job
/// </summary>
[Fact]
internal async Task TestUpdateNonExistentJob()
[Test]
public async Task TestUpdateNonExistentJob()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -219,8 +219,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// update notebook handler with garbage path
/// </summary>
[Fact]
internal async Task TestUpdateWithGarbagePath()
[Test]
public async Task TestUpdateWithGarbagePath()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -230,7 +230,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
//seting up a temp notebook job
var notebook = AgentTestUtils.SetupNotebookJob(connectionResult).Result;
//verifying that the notebook is created
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
var updateNotebookContext = new Mock<RequestContext<UpdateAgentNotebookResult>>();
updateNotebookContext.Setup(x => x.SendResult(It.IsAny<UpdateAgentNotebookResult>())).Returns(Task.FromResult(new object()));
@@ -246,12 +246,12 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
//cleaning up the job
await AgentTestUtils.CleanupNotebookJob(connectionResult, notebook);
Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
}
}
[Fact]
internal async Task TestDeletingUpdatedJob()
[Test]
public async Task TestDeletingUpdatedJob()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -261,13 +261,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
//seting up a temp notebook job
var notebook = AgentTestUtils.SetupNotebookJob(connectionResult).Result;
//verifying that the notebook is created
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
var originalName = notebook.Name;
//Changing the notebookName
notebook.Name = "myTestNotebookJob" + Guid.NewGuid().ToString();
Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
await AgentNotebookHelper.UpdateNotebook(
service,
@@ -278,7 +278,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
ManagementUtils.asRunType(0)
);
Assert.Equal(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
Assert.AreEqual(true, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
//cleaning up the job
await AgentTestUtils.CleanupNotebookJob(connectionResult, notebook);

View File

@@ -10,7 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -19,7 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify default agent/operators handlers
/// </summary>
[Fact]
[Test]
public async Task TestHandleAgentOperatorsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -41,7 +41,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify the default "create agent alert" request handler with valid parameters
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -63,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleUpdateAgentOperatorRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleDeleteAgentOperatorRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleDeleteAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -14,7 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Security.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
@@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify default agent/proxies handlers
/// </summary>
[Fact]
[Test]
public async Task TestHandleAgentProxiesRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleCreateAgentProxyRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify the default "update agent alert" request handler with valid parameters
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -96,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleDeleteAgentProxyRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleDeleteAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -11,7 +11,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// HandleAgentSchedulesRequest
/// </summary>
[Fact]
[Test]
public async Task HandleAgentSchedulesRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleCreateAgentScheduleRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleCreateAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleUpdateAgentScheduleRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleUpdateAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -95,7 +95,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleDeleteAgentScheduleRequest
/// </summary>
[Fact]
[Test]
public async Task TestHandleDeleteAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())

View File

@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify that a start profiling request starts a profiling session
/// </summary>
[Fact]
[Test]
public async Task TestHandleAgentJobsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// Verify that a job history request returns the job history
/// </summary>
[Fact]
[Test]
public async Task TestHandleJobHistoryRequests()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -65,7 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
}
}
[Fact]
[Test]
public async Task TestHandleAgentJobActionRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())