mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-25 17:24:17 -05:00
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:
@@ -13,7 +13,7 @@ using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Contracts;
|
||||
using Microsoft.SqlTools.ResourceProvider.DefaultImpl;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
{
|
||||
@@ -29,14 +29,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
serviceProvider.RegisterSingleService<IAzureResourceManager>(resourceManagerMock.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task CurrentUserShouldBeNullWhenUserIsNotSignedIn()
|
||||
{
|
||||
IAzureAuthenticationManager accountManager = await CreateAccountManager(null, null);
|
||||
Assert.Null(await accountManager.GetCurrentAccountAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetSubscriptionShouldReturnEmptyWhenUserIsNotSignedIn()
|
||||
{
|
||||
IAzureAuthenticationManager accountManager = await CreateAccountManager(null, null);
|
||||
@@ -45,24 +45,24 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
Assert.False(result.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetSubscriptionShouldThrowWhenUserNeedsAuthentication()
|
||||
{
|
||||
var currentUserAccount = CreateAccount();
|
||||
currentUserAccount.Account.IsStale = true;
|
||||
IAzureAuthenticationManager accountManager = await CreateAccountManager(currentUserAccount, null);
|
||||
await Assert.ThrowsAsync<ExpiredTokenException>(() => accountManager.GetSelectedSubscriptionsAsync());
|
||||
Assert.ThrowsAsync<ExpiredTokenException>(() => accountManager.GetSelectedSubscriptionsAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetSubscriptionShouldThrowIfFailed()
|
||||
{
|
||||
var currentUserAccount = CreateAccount();
|
||||
IAzureAuthenticationManager accountManager = await CreateAccountManager(currentUserAccount, null, true);
|
||||
await Assert.ThrowsAsync<ServiceFailedException>(() => accountManager.GetSelectedSubscriptionsAsync());
|
||||
Assert.ThrowsAsync<ServiceFailedException>(() => accountManager.GetSelectedSubscriptionsAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetSubscriptionShouldReturnTheListSuccessfully()
|
||||
{
|
||||
List<IAzureUserAccountSubscriptionContext> subscriptions = new List<IAzureUserAccountSubscriptionContext> {
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Fakes;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
/// </summary>
|
||||
public class AzureDatabaseDiscoveryProviderTest
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnDatabasesSuccessfully()
|
||||
{
|
||||
string databaseName1 = "server/db1";
|
||||
@@ -51,7 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
Assert.True(list.Count() == 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnDatabasesEvenIfFailsForOneServer()
|
||||
{
|
||||
string databaseName1 = "server1/db1";
|
||||
@@ -85,7 +85,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
Assert.True(response.Errors.Count() == 1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnDatabasesFromCacheIfGetCalledTwice()
|
||||
{
|
||||
Dictionary<string, List<string>> subscriptionToDatabaseMap = CreateSubscriptonMap(2);
|
||||
@@ -107,7 +107,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
ValidateResult(subscriptionToDatabaseMap, list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnDatabasesFromServiceIfGetCalledTwiceButRefreshed()
|
||||
{
|
||||
Dictionary<string, List<string>> subscriptionToDatabaseMap = CreateSubscriptonMap(2);
|
||||
@@ -187,7 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
return subscriptionToDatabaseMapCopy;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnEmptyGivenNotSubscriptionFound()
|
||||
{
|
||||
Dictionary<string, List<string>> subscriptionToDatabaseMap = new Dictionary<string, List<string>>();
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
using Microsoft.Azure.Management.Sql.Models;
|
||||
using Microsoft.SqlTools.ResourceProvider.DefaultImpl;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
{
|
||||
public class AzureResourceWrapperTest
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public void ShouldParseResourceGroupFromId()
|
||||
{
|
||||
// Given a resource with a known resource group
|
||||
@@ -25,10 +25,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
string rgName = resource.ResourceGroupName;
|
||||
|
||||
// then I get it as expected
|
||||
Assert.Equal("myresourcegroup", rgName);
|
||||
Assert.AreEqual("myresourcegroup", rgName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void ShouldHandleMissingResourceGroup()
|
||||
{
|
||||
// Given a resource without resource group in the ID
|
||||
@@ -42,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
string rgName = resource.ResourceGroupName;
|
||||
|
||||
// then I get string.Empty
|
||||
Assert.Equal(string.Empty, rgName);
|
||||
Assert.AreEqual(string.Empty, rgName);
|
||||
}
|
||||
|
||||
private TrackedResource CreateMockResource(string id = null, string name = null, string type = null)
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Fakes;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
/// </summary>
|
||||
public class AzureSqlServerDiscoveryProviderTest
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnServersSuccessfully()
|
||||
{
|
||||
string serverName = "server";
|
||||
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
Assert.True(servers.Count() == 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public async Task GetShouldReturnEmptyGivenNoSubscriptionFound()
|
||||
{
|
||||
Dictionary<string, List<string>> subscriptionToDatabaseMap = new Dictionary<string, List<string>>();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.ResourceProvider.DefaultImpl;
|
||||
using Xunit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
/// </summary>
|
||||
public class AzureSubscriptionContextTest
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SubscriptionNameShouldReturnNullGivenNullSubscription()
|
||||
{
|
||||
AzureSubscriptionContext subscriptionContext = new AzureSubscriptionContext(null);
|
||||
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider.Azure
|
||||
Assert.True(subscriptionContext.Subscription == null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Test]
|
||||
public void SubscriptionNameShouldReturnCorrectValueGivenValidSubscription()
|
||||
{
|
||||
string name = Guid.NewGuid().ToString();
|
||||
|
||||
Reference in New Issue
Block a user