diff --git a/Packages.props b/Packages.props
index 3c26efa4..dcd131c0 100644
--- a/Packages.props
+++ b/Packages.props
@@ -23,6 +23,8 @@
+
+
diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml
index d4c87d7d..b26a3526 100644
--- a/azure-pipelines/build.yml
+++ b/azure-pipelines/build.yml
@@ -1,5 +1,5 @@
pool:
- name: Hosted VS2017
+ vmImage: 'windows-latest'
demands:
- Cmd
- npm
diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/Batch.cs b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/Batch.cs
index 2321becf..1e1c6c5f 100644
--- a/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/Batch.cs
+++ b/src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/ExecutionEngineCode/Batch.cs
@@ -683,23 +683,23 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
DbConnectionWrapper connectionWrapper = new DbConnectionWrapper(connection);
connectionWrapper.InfoMessage += messageHandler;
- IDbCommand command = connection.CreateCommand();
- command.CommandText = script;
- command.CommandTimeout = execTimeout;
+ IDbCommand localCommand = connection.CreateCommand();
+ localCommand.CommandText = script;
+ localCommand.CommandTimeout = execTimeout;
DbCommandWrapper commandWrapper = null;
- if (isScriptExecutionTracked && DbCommandWrapper.IsSupportedCommand(command))
+ if (isScriptExecutionTracked && DbCommandWrapper.IsSupportedCommand(localCommand))
{
statementCompletedHandler = new StatementCompletedEventHandler(OnStatementExecutionFinished);
- commandWrapper = new DbCommandWrapper(command);
+ commandWrapper = new DbCommandWrapper(localCommand);
commandWrapper.StatementCompleted += statementCompletedHandler;
}
lock (this)
{
state = BatchState.Executing;
- this.command = command;
- command = null;
+ command = localCommand;
+ localCommand = null;
}
try
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
index 2ca2cd79..9007d1d9 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
+++ b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
@@ -20,7 +20,7 @@
-
+
@@ -45,4 +45,23 @@
+
+
+
+
+
+
+
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs
index 0e030e74..3ba56157 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/CommonObjects.cs
@@ -8,7 +8,8 @@ using Microsoft.SqlTools.Hosting.Contracts;
using Microsoft.SqlTools.Hosting.Contracts.Internal;
using Microsoft.SqlTools.Hosting.Protocol;
using Newtonsoft.Json.Linq;
-
+using NUnit.Framework.Interfaces;
+
namespace Microsoft.SqlTools.Hosting.UnitTests
{
public static class CommonObjects
@@ -51,6 +52,15 @@ namespace Microsoft.SqlTools.Hosting.UnitTests
&& Number == other.Number;
}
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as TestMessageContents);
+ }
+
+ public override int GetHashCode()
+ {
+ return SomeField.GetHashCode() ^ Number;
+ }
public static bool operator ==(TestMessageContents obj1, TestMessageContents obj2)
{
bool bothNull = ReferenceEquals(obj1, null) && ReferenceEquals(obj2, null);
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsIntConverterTests.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsIntConverterTests.cs
index a67b3630..9e369e5e 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsIntConverterTests.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsIntConverterTests.cs
@@ -1,38 +1,39 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
using Microsoft.SqlTools.DataProtocol.Contracts.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
{
+ [TestFixture]
public class FlagsIntConverterTests
{
- [Fact]
+ [Test]
public void NullableValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": [1, 2]}");
var contract = jsonObject.ToObject();
Assert.NotNull(contract);
Assert.NotNull(contract.OptionalValue);
- Assert.Equal(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
+ Assert.AreEqual(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
}
- [Fact]
+ [Test]
public void RegularValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"Value\": [1, 3]}");
var contract = jsonObject.ToObject();
Assert.NotNull(contract);
- Assert.Equal(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
+ Assert.AreEqual(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
}
- [Fact]
+ [Test]
public void ExplicitNullCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": null}");
@@ -42,7 +43,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
}
[Flags]
- [JsonConverter(typeof(FlagsIntConverter))]
+ [JsonConverter(typeof(FlagsIntConverter))]
private enum TestFlags
{
[FlagsIntConverter.SerializeValue(1)]
@@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
SecondItem = 1 << 1,
[FlagsIntConverter.SerializeValue(3)]
- ThirdItem = 1 << 2,
+ ThirdItem = 1 << 2,
}
private class DataContract
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsStringConverterTests.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsStringConverterTests.cs
index aaa53970..a73f2b10 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsStringConverterTests.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/Contracts/Utilities/FlagsStringConverterTests.cs
@@ -1,38 +1,39 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
using System;
using Microsoft.SqlTools.DataProtocol.Contracts.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
{
+ [TestFixture]
public class FlagsStringConverterTests
{
- [Fact]
+ [Test]
public void NullableValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": [\"First\", \"Second\"]}");
var contract = jsonObject.ToObject();
Assert.NotNull(contract);
Assert.NotNull(contract.OptionalValue);
- Assert.Equal(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
+ Assert.AreEqual(TestFlags.FirstItem | TestFlags.SecondItem, contract.OptionalValue);
}
- [Fact]
+ [Test]
public void RegularValueCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"Value\": [\"First\", \"Third\"]}");
var contract = jsonObject.ToObject();
Assert.NotNull(contract);
- Assert.Equal(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
+ Assert.AreEqual(TestFlags.FirstItem | TestFlags.ThirdItem, contract.Value);
}
- [Fact]
+ [Test]
public void ExplicitNullCanBeDeserialized()
{
var jsonObject = JObject.Parse("{\"optionalValue\": null}");
@@ -42,7 +43,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
}
[Flags]
- [JsonConverter(typeof(FlagsStringConverter))]
+ [JsonConverter(typeof(FlagsStringConverter))]
private enum TestFlags
{
[FlagsStringConverter.SerializeValue("First")]
@@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.Contracts.Utilities
SecondItem = 1 << 1,
[FlagsStringConverter.SerializeValue("Third")]
- ThirdItem = 1 << 2,
+ ThirdItem = 1 << 2,
}
private class DataContract
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/ExtensibilityTests/ServiceProviderTests.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/ExtensibilityTests/ServiceProviderTests.cs
index 93aa311f..f602cbe3 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/ExtensibilityTests/ServiceProviderTests.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/ExtensibilityTests/ServiceProviderTests.cs
@@ -7,19 +7,23 @@ using System;
using System.Linq;
using Microsoft.SqlTools.Hosting.Extensibility;
using Microsoft.SqlTools.Hosting.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.ExtensibilityTests
{
+
+ [TestFixture]
public class ServiceProviderTests
{
- private readonly RegisteredServiceProvider provider;
- public ServiceProviderTests()
+ private RegisteredServiceProvider provider;
+
+ [SetUp]
+ public void SetupServiceProviderTests()
{
provider = new RegisteredServiceProvider();
- }
+ }
- [Fact]
+ [Test]
public void GetServiceShouldReturnNullIfNoServicesRegistered()
{
// Given no service registered
@@ -30,7 +34,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ExtensibilityTests
}
- [Fact]
+ [Test]
public void GetSingleServiceThrowsMultipleServicesRegistered()
{
// Given 2 services registered
@@ -40,44 +44,43 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ExtensibilityTests
Assert.Throws(() => provider.GetService());
}
- [Fact]
+ [Test]
public void GetServicesShouldReturnEmptyIfNoServicesRegistered()
{
// Given no service regisstered
// When I call GetService
var services = provider.GetServices();
- // Then I expect empty enumerable to be returned
- Assert.NotNull(services);
- Assert.Empty(services);
+ Assert.That(services, Is.Empty, "provider.GetServices with no service registered");
}
- [Fact]
+ [Test]
public void GetServiceShouldReturnRegisteredService()
{
MyProviderService service = new MyProviderService();
provider.RegisterSingleService(service);
var returnedService = provider.GetService();
- Assert.Equal(service, returnedService);
+ Assert.AreEqual(service, returnedService);
}
- [Fact]
+ // DEVNOTE: The name of this test doesn't match the code, which is pretty much the same as the one above.
+ [Test]
public void GetServicesShouldReturnRegisteredServiceWhenMultipleServicesRegistered()
{
MyProviderService service = new MyProviderService();
- provider.RegisterSingleService(service);
+ provider.RegisterSingleService(service);
var returnedServices = provider.GetServices();
- Assert.Equal(service, returnedServices.Single());
+ Assert.AreEqual(service, returnedServices.Single());
}
- [Fact]
+ [Test]
public void RegisterServiceProviderShouldThrowIfServiceIsIncompatible()
{
MyProviderService service = new MyProviderService();
Assert.Throws(() => provider.RegisterSingleService(typeof(OtherService), service));
}
- [Fact]
+ [Test]
public void RegisterServiceProviderShouldThrowIfServiceAlreadyRegistered()
{
MyProviderService service = new MyProviderService();
@@ -86,7 +89,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ExtensibilityTests
Assert.Throws(() => provider.RegisterSingleService(service));
}
- [Fact]
+ [Test]
public void RegisterShouldThrowIfServiceAlreadyRegistered()
{
MyProviderService service = new MyProviderService();
@@ -95,7 +98,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ExtensibilityTests
Assert.Throws(() => provider.Register(() => service.AsSingleItemEnumerable()));
}
- [Fact]
+ [Test]
public void RegisterShouldThrowIfServicesAlreadyRegistered()
{
provider.Register(() => new [] { new MyProviderService(), new MyProviderService() });
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/Microsoft.SqlTools.Hosting.UnitTests.csproj b/test/Microsoft.SqlTools.Hosting.UnitTests/Microsoft.SqlTools.Hosting.UnitTests.csproj
index 43412e5a..01a43f55 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/Microsoft.SqlTools.Hosting.UnitTests.csproj
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/Microsoft.SqlTools.Hosting.UnitTests.csproj
@@ -7,8 +7,9 @@
-
-
+
+
+
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/EventContextTests.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/EventContextTests.cs
index 0f816107..8efd32a4 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/EventContextTests.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/EventContextTests.cs
@@ -4,14 +4,16 @@
//
using System.Collections.Concurrent;
+using System.Linq;
using Microsoft.SqlTools.Hosting.Protocol;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
{
+ [TestFixture]
public class EventContextTests
{
- [Fact]
+ [Test]
public void SendEvent()
{
// Setup: Create collection
@@ -20,11 +22,11 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
// If: I construct an event context with a message writer
// And send an event with it
var eventContext = new EventContext(bc);
- eventContext.SendEvent(CommonObjects.EventType, CommonObjects.TestMessageContents.DefaultInstance);
-
- // Then: The message should be added to the queue
- Assert.Single(bc.ToArray());
- Assert.Equal(MessageType.Event, bc.ToArray()[0].MessageType);
+ eventContext.SendEvent(CommonObjects.EventType, CommonObjects.TestMessageContents.DefaultInstance);
+
+ // Then: The message should be added to the queue
+ var messages = bc.ToArray().Select(m => m.MessageType);
+ Assert.That(messages, Is.EqualTo(new[] { MessageType.Event }), "Single message of type event in the queue after SendEvent");
}
}
}
\ No newline at end of file
diff --git a/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/JsonRpcHostTests.cs b/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/JsonRpcHostTests.cs
index 402d6160..0122d04d 100644
--- a/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/JsonRpcHostTests.cs
+++ b/test/Microsoft.SqlTools.Hosting.UnitTests/ProtocolTests/JsonRpcHostTests.cs
@@ -12,13 +12,14 @@ using Microsoft.SqlTools.Hosting.Channels;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
{
+ [TestFixture]
public class JsonRpcHostTests
{
- [Fact]
+ [Test]
public void ConstructWithNullProtocolChannel()
{
// If: I construct a JSON RPC host with a null protocol channel
@@ -28,7 +29,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
#region SetRequestHandler Tests
- [Fact]
+ [Test]
public void SetAsyncRequestHandlerNullRequestType()
{
// If: I assign a request handler on the JSON RPC host with a null request type
@@ -38,7 +39,7 @@ namespace Microsoft.SqlTools.Hosting.UnitTests.ProtocolTests
jh.SetAsyncRequestHandler
diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/ExecutionEngineTest.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/ExecutionEngineTest.cs
index 11e3618c..7dc4c41d 100644
--- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/ExecutionEngineTest.cs
+++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/ExecutionEngineTest.cs
@@ -12,15 +12,16 @@ using Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
+
+ [TestFixture]
///
///This is a test class for Microsoft.Data.Tools.Schema.Common.ExecutionEngine.ExecutionEngine and is intended
///to contain all Microsoft.Data.Tools.Schema.Common.ExecutionEngine.ExecutionEngine Unit Tests
///
-
public class ExecutionEngineTest : IDisposable
{
private SqlConnection connection;
@@ -29,11 +30,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Test Initialize And Cleanup
- public ExecutionEngineTest()
- {
- TestInitialize();
- }
-
+ [SetUp]
// Initialize the tests
public void TestInitialize()
{
@@ -80,7 +77,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
///A test for a simple SQL script
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_SimpleTest()
{
string sqlStatement = "SELECT * FROM sysobjects";
@@ -97,15 +94,15 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
- Assert.Equal(1, executor.BatchFinshedEventCounter);
+ Assert.AreEqual(1, executor.BatchFinshedEventCounter);
}
///
/// Test with a valid script using default execution condition
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_DefaultCondition_ValidScript()
{
string sqlStatement = "select * from sysobjects\nGo\n";
@@ -119,14 +116,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
//
// Test with multiple valid scripts in multiple batches
//
- [Fact]
+ [Test]
public void ExecutionEngineTest_MultiValidScripts()
{
string sqlStatement = "select * from sys.databases\ngo\nselect name from sys.databases\ngo\nprint 'test'\ngo";
@@ -143,14 +140,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
///
/// Test with SQL comment
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_TestComment()
{
string sqlStatement = "/*test comments*/";
@@ -167,7 +164,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
@@ -178,7 +175,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with a invalid query using the default execution condition
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_DefaultCondition_InvalidScript()
{
string sqlStatement = "select ** from sysobjects";
@@ -192,17 +189,17 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
- Assert.Equal(0, executor.BatchFinshedEventCounter);
+ Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
///
/// Test with an invalid query using a defined execution condition
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_InvalidScriptWithCondition()
{
string sqlStatement = "select * from authors";
@@ -218,7 +215,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
+ Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -227,7 +224,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with multiple invalid scripts in multiple batches
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_MultipleInvalidScript()
{
string sqlStatement = "select ** from products \ngo\n insert into products values (1,'abc')\n go \n";
@@ -244,7 +241,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
+ Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -253,7 +250,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with invalid scripts within a single batch
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_MultipleInvalidScript_SingleBatch()
{
string sqlStatement = "select ** from products \n insert into products values (1,'abc')\n go \n";
@@ -270,7 +267,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
@@ -279,7 +276,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with mixed valid and invalid scripts
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_MixedValidandInvalidScript()
{
string sqlStatement = "SELECT * FROM Authors \n Go\n select * from sysobjects \n go\nif exists (select * from sysobjects where id = object_id('MyTab')) DROP TABLE MyTab2";
@@ -296,13 +293,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
+ Assert.AreEqual(executor.ExecutionResult, ScriptExecutionResult.Success | ScriptExecutionResult.Failure);
Assert.True(!executor.ParserExecutionError);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
- [Fact]
+ [Test]
public void ExecutionEngineTest_DiscardConnection()
{
ExecutionEngine engine = new ExecutionEngine();
@@ -316,14 +313,16 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test HaltOnError execution condition
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_HaltOnError()
{
string sqlStatement = "select * from authors\n go\n select * from sysbojects \n go \n";
- ExecutionEngineConditions conditions = new ExecutionEngineConditions();
- conditions.IsTransactionWrapped = true;
- conditions.IsParseOnly = false;
- conditions.IsHaltOnError = true;
+ ExecutionEngineConditions conditions = new ExecutionEngineConditions
+ {
+ IsTransactionWrapped = true,
+ IsParseOnly = false,
+ IsHaltOnError = true
+ };
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
@@ -332,7 +331,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.True(executor.ResultCountQueue.Count == 0);
@@ -341,7 +340,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// HaltOnError with a single batch
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_HaltOnError_OneBatch()
{
string sqlStatement = "select * from authors\n go 30\n";
@@ -357,17 +356,17 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Halted | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
Assert.True(executor.ResultCountQueue.Count == 0);
- Assert.Equal(0, executor.BatchFinshedEventCounter);
+ Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
///
/// Test ParseOnly execution condition with valid scripts
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_ParseOnly_ValidScript()
{
string sqlStatement = "select * from sysobjects";
@@ -379,15 +378,15 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(executor.ResultCountQueue.Count == 0);
- Assert.Equal(0, executor.BatchFinshedEventCounter);
+ Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
///
/// Test HaltOnError execution condition with invalid scripts
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_ParseOnly_InvalidScript()
{
string sqlStatement = "select ** from authors";
@@ -403,7 +402,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Failure, executor.ExecutionResult);
Assert.True(!executor.ParserExecutionError);
Assert.True(executor.ResultCountQueue.Count == 0);
Assert.True(CompareTwoStringLists(executor.ErrorMessageQueue, expErrorMessage));
@@ -412,7 +411,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Parse script only without transaction wrapper
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_ParseOnly_ValidScriptWithoutTransaction()
{
string sqlStatement = "select * from sysobjects";
@@ -424,9 +423,9 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions);
executor.Run();
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(executor.ResultCountQueue.Count == 0);
- Assert.Equal(0, executor.BatchFinshedEventCounter);
+ Assert.AreEqual(0, executor.BatchFinshedEventCounter);
}
///
@@ -443,13 +442,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
TestExecutor executor = new TestExecutor(sqlStatement, connection, conditions, -1);
executor.Run();
- Assert.Equal(executor.ExecutionResult, ScriptExecutionResult.Success);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
}
///
/// Test with invalid connection
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_InvalidConnection()
{
string sqlStatement = "select * from sysobjects\n go 100\n";
@@ -470,7 +469,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with multiple conditions true
///
- [Fact]
+ [Test]
public void TestExecutionEngineConditions()
{
string sqlStatement = "select * from sys.databases\ngo\nselect name from sys.databases\ngo\nprint 'test'\ngo";
@@ -486,7 +485,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
List batchScripts = executor.BatchScripts;
ExecuteSqlBatch(batchScripts, connection);
- Assert.Equal(ScriptExecutionResult.Success, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success, executor.ExecutionResult);
Assert.True(CompareTwoIntLists(executor.ResultCountQueue, expResultCounts));
}
@@ -497,7 +496,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test with SQL commands
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_SQLCmds()
{
string[] sqlStatements = {
@@ -537,7 +536,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
/// Test synchronous cancel
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_SyncCancel()
{
string sqlStatement = "waitfor delay '0:0:10'";
@@ -552,14 +551,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
executor.Run();
Assert.NotNull(executor.ScriptExecuteThread);
- Assert.Equal(ScriptExecutionResult.Cancel, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Cancel, executor.ExecutionResult);
Assert.True(executor.CancelEventFired);
}
///
/// Test asynchronous cancel
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_ASyncCancel()
{
//string sqlStatement = "--This is a test\nSELECT * FROM sysobjects as t\nGO 50\n use pubsplus \n select * from titles\n go" ;
@@ -578,7 +577,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
- Assert.Equal(ScriptExecutionResult.Cancel, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
///
@@ -604,13 +603,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
- Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
///
/// Test async cancel when the execution is done
///
- [Fact]
+ [Test]
public void ExecutionEngineTest_ASyncCancelAfterExecutionDone()
{
string sqlStatement = "select 1";
@@ -628,13 +627,13 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(executor.ScriptExecuteThread);
if (executor.ScriptExecuteThread != null)
Assert.True(!executor.ScriptExecuteThread.IsAlive);
- Assert.Equal(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
+ Assert.AreEqual(ScriptExecutionResult.Success | ScriptExecutionResult.Cancel, executor.ExecutionResult);
}
///
/// Test multiple threads of execution engine with cancel operation
///
- [Fact]
+ [Test]
public async Task ExecutionEngineTest_MultiThreading_WithCancel()
{
string[] sqlStatement = { "waitfor delay '0:0:10'",
@@ -693,7 +692,7 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Get/Set Methods
- [Fact]
+ [Test]
public void TestShowStatements()
{
Assert.NotNull(ExecutionEngineConditions.ShowPlanXmlStatement(true));
@@ -708,48 +707,48 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Assert.NotNull(ExecutionEngineConditions.ResetStatement);
}
- [Fact]
+ [Test]
public void TestExecutionEngineConditionsSetMethods()
{
ExecutionEngineConditions conditions = new ExecutionEngineConditions();
bool getValue = conditions.IsScriptExecutionTracked;
conditions.IsScriptExecutionTracked = !getValue;
- Assert.Equal(conditions.IsScriptExecutionTracked, !getValue);
+ Assert.AreEqual(conditions.IsScriptExecutionTracked, !getValue);
getValue = conditions.IsEstimatedShowPlan;
conditions.IsEstimatedShowPlan = !getValue;
- Assert.Equal(conditions.IsEstimatedShowPlan, !getValue);
+ Assert.AreEqual(conditions.IsEstimatedShowPlan, !getValue);
getValue = conditions.IsActualShowPlan;
conditions.IsActualShowPlan = !getValue;
- Assert.Equal(conditions.IsActualShowPlan, !getValue);
+ Assert.AreEqual(conditions.IsActualShowPlan, !getValue);
getValue = conditions.IsSuppressProviderMessageHeaders;
conditions.IsSuppressProviderMessageHeaders = !getValue;
- Assert.Equal(conditions.IsSuppressProviderMessageHeaders, !getValue);
+ Assert.AreEqual(conditions.IsSuppressProviderMessageHeaders, !getValue);
getValue = conditions.IsNoExec;
conditions.IsNoExec = !getValue;
- Assert.Equal(conditions.IsNoExec, !getValue);
+ Assert.AreEqual(conditions.IsNoExec, !getValue);
getValue = conditions.IsStatisticsIO;
conditions.IsStatisticsIO = !getValue;
- Assert.Equal(conditions.IsStatisticsIO, !getValue);
+ Assert.AreEqual(conditions.IsStatisticsIO, !getValue);
getValue = conditions.IsShowPlanText;
conditions.IsShowPlanText = !getValue;
- Assert.Equal(conditions.IsShowPlanText, !getValue);
+ Assert.AreEqual(conditions.IsShowPlanText, !getValue);
getValue = conditions.IsStatisticsTime;
conditions.IsStatisticsTime = !getValue;
- Assert.Equal(conditions.IsStatisticsTime, !getValue);
+ Assert.AreEqual(conditions.IsStatisticsTime, !getValue);
getValue = conditions.IsSqlCmd;
conditions.IsSqlCmd = !getValue;
- Assert.Equal(conditions.IsSqlCmd, !getValue);
+ Assert.AreEqual(conditions.IsSqlCmd, !getValue);
conditions.BatchSeparator = "GO";
- Assert.Equal(conditions.BatchSeparator, "GO");
+ Assert.AreEqual("GO", conditions.BatchSeparator);
}
#endregion Get/Set Methods
diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs
index 63f40769..cbaff188 100644
--- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs
+++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/TSQLExecutionEngine/TestExecutor.cs
@@ -9,7 +9,8 @@ using Microsoft.Data.SqlClient;
using System.Threading;
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
using Microsoft.SqlTools.Utility;
-
+using System.Runtime.CompilerServices;
+
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEngine
{
internal class TestExecutor : IDisposable
@@ -17,9 +18,9 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
#region Private variables
private string sqlStatement;
- private ExecutionEngineConditions conditions = new ExecutionEngineConditions();
- private BatchEventHandler eventHandler = new BatchEventHandler();
- private SqlConnection connection = null;
+ private readonly ExecutionEngineConditions conditions = new ExecutionEngineConditions();
+ private readonly BatchEventHandler eventHandler = new BatchEventHandler();
+ private readonly SqlConnection connection;
private static Thread _executionThread;
private bool _syncCancel = true;
private bool _isFinished = false;
@@ -31,12 +32,12 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
private List resultCounts = new List();
private List sqlMessages = new List();
- private List errorMessage = new List();
+ private readonly List errorMessage = new List();
private List batchFinished = new List();
private static ScriptExecutionResult execResult = ScriptExecutionResult.All;
private static List batchScripts = new List();
private static Thread exeThread = null;
- private static bool parserExecutionError = false;
+ private bool parserExecutionError = false;
#endregion Private variables
@@ -322,10 +323,14 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
private static void OnBatchParserExecutionFinished(object sender, BatchParserExecutionFinishedEventArgs e)
{
Console.WriteLine("ON_BATCH_PARSER_EXECUTION_FINISHED : Done executing batch \n\t{0}\n\t with result... {1} ", e.Batch.Text, e.ExecutionResult);
- if (execResult == ScriptExecutionResult.All)
- execResult = e.ExecutionResult;
- else
- execResult = execResult | e.ExecutionResult;
+ if (execResult == ScriptExecutionResult.All)
+ {
+ execResult = e.ExecutionResult;
+ }
+ else
+ {
+ execResult |= e.ExecutionResult;
+ }
}
///
@@ -333,11 +338,12 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
///
///
///
- private static void OnBatchParserExecutionError(object sender, BatchParserExecutionErrorEventArgs e)
+ private void OnBatchParserExecutionError(object sender, BatchParserExecutionErrorEventArgs e)
{
Console.WriteLine("ON_BATCH_PARSER_EXECUTION_ERROR : {0} found... at line {1}: {2}", e.MessageType.ToString(), e.Line.ToString(), e.Message);
Console.WriteLine("\t Error Description: " + e.Description);
parserExecutionError = true;
+ errorMessage.Add(e.Description);
}
///
@@ -350,14 +356,18 @@ namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.TSQLExecutionEn
Console.WriteLine("ON_EXECUTION_FINISHED : Script execution done with result ..." + e.ExecutionResult);
_isFinished = true;
- if (execResult == ScriptExecutionResult.All)
- execResult = e.ExecutionResult;
- else
- execResult = execResult | e.ExecutionResult;
+ if (execResult == ScriptExecutionResult.All)
+ {
+ execResult = e.ExecutionResult;
+ }
+ else
+ {
+ execResult |= e.ExecutionResult;
+ }
resultCounts = eventHandler.ResultCounts;
sqlMessages = eventHandler.SqlMessages;
- errorMessage = eventHandler.ErrorMessages;
+ errorMessage.AddRange(eventHandler.ErrorMessages);
}
#endregion ParserEvent
diff --git a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/LiveConnectionHelper.cs b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/LiveConnectionHelper.cs
index a83beea8..574ffbb7 100644
--- a/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/LiveConnectionHelper.cs
+++ b/test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests/Utility/LiveConnectionHelper.cs
@@ -8,7 +8,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ManagedBatchParser.IntegrationTests.Utility
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Admin/DatabaseAdminTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Admin/DatabaseAdminTests.cs
index 0a81a287..7f00b52e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Admin/DatabaseAdminTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Admin/DatabaseAdminTests.cs
@@ -10,7 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
using Moq;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
@@ -44,8 +44,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
///
/// Validate creating a database with valid input
///
- // [Fact]
- public async void CreateDatabaseWithValidInputTest()
+ // [Test]
+ public async Task CreateDatabaseWithValidInputTest()
{
var result = GetLiveAutoCompleteTestObjects();
var requestContext = new Mock>();
@@ -68,8 +68,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
///
/// Get a default database info object
///
- // [Fact]
- public async void GetDefaultDatebaseInfoTest()
+ // [Test]
+ public async Task GetDefaultDatebaseInfoTest()
{
var result = GetLiveAutoCompleteTestObjects();
var requestContext = new Mock>();
@@ -89,8 +89,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AdminServices
/// Get database info test
///
/// Test is failing in code coverage runs. Reenable when stable.
- /// [Fact]
- public async void GetDatabaseInfoTest()
+ /// [Test]
+ public async Task GetDatabaseInfoTest()
{
var results = GetLiveAutoCompleteTestObjects();
var requestContext = new Mock>();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentAlertTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentAlertTests.cs
index 82c586e4..79d8ef57 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentAlertTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentAlertTests.cs
@@ -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
///
/// Verify default agent/alerts handlers
///
- [Fact]
+ [Test]
public async Task TestHandleAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -42,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Verify the default "create agent alert" request handler with valid parameters
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Verify the default "update agent alert" request handler with valid parameters
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentAlertsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobStepTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobStepTests.cs
index 225ba692..7b24064e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobStepTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobStepTests.cs
@@ -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
///
/// TestHandleCreateAgentJobStepRequest
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleUpdateAgentJobStepRequest
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -71,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleDeleteAgentJobRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteAgentJobStepRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobTests.cs
index 069a57f2..848910fc 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentJobTests.cs
@@ -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
///
/// TestHandleCreateAgentJobRequest
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -43,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleUpdateAgentJobRequest
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -66,7 +66,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleDeleteAgentJobRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestAgentJobDefaultsRequest
///
- [Fact]
+ [Test]
public async Task TestAgentJobDefaultsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentNotebookTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentNotebookTests.cs
index 28f0d717..88257a5d 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentNotebookTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentNotebookTests.cs
@@ -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
///
/// Test case for fetch notebook jobs Request Handler
///
- [Fact]
+ [Test]
public async Task TestHandleAgentNotebooksRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -40,16 +40,16 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Tests the create job helper function
///
- [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
///
/// Tests the create job request handler with an invalid file path
///
- [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(p => p.Success == false)));
- Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
+ Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
}
}
///
/// creating a job with duplicate name
///
- [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
///
/// Tests the create notebook job handler
///
- [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(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
///
/// Tests the delete notebook job handler
///
- [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>();
deleteNotebookContext.Setup(x => x.SendResult(It.IsAny())).Returns(Task.FromResult(new object()));
@@ -161,15 +161,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
}, deleteNotebookContext.Object);
deleteNotebookContext.Verify(x => x.SendResult(It.Is(p => p.Success == true)));
//verifying if the job is deleted
- Assert.Equal(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
+ Assert.AreEqual(false, AgentTestUtils.VerifyNotebook(connectionResult, notebook));
}
}
///
/// deleting a existing notebook job
///
- [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
///
/// updating a non existing notebook job
///
- [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
///
/// update notebook handler with garbage path
///
- [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>();
updateNotebookContext.Setup(x => x.SendResult(It.IsAny())).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);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentOperatorTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentOperatorTests.cs
index 9d052f97..9b03a3fe 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentOperatorTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentOperatorTests.cs
@@ -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
///
/// Verify default agent/operators handlers
///
- [Fact]
+ [Test]
public async Task TestHandleAgentOperatorsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -41,7 +41,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Verify the default "create agent alert" request handler with valid parameters
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -63,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleUpdateAgentOperatorRequest
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleDeleteAgentOperatorRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteAgentOperatorRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentProxyTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentProxyTests.cs
index 291dde38..348cd8d3 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentProxyTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentProxyTests.cs
@@ -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
///
/// Verify default agent/proxies handlers
///
- [Fact]
+ [Test]
public async Task TestHandleAgentProxiesRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleCreateAgentProxyRequest
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Verify the default "update agent alert" request handler with valid parameters
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -96,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleDeleteAgentProxyRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteAgentProxyRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentScheduleTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentScheduleTests.cs
index 3fbc6c77..7c7bbb92 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentScheduleTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentScheduleTests.cs
@@ -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
///
/// HandleAgentSchedulesRequest
///
- [Fact]
+ [Test]
public async Task HandleAgentSchedulesRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleCreateAgentScheduleRequest
///
- [Fact]
+ [Test]
public async Task TestHandleCreateAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleUpdateAgentScheduleRequest
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -95,7 +95,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// TestHandleDeleteAgentScheduleRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteAgentScheduleRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentServiceTests.cs
index 1e670d35..6094e8a8 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Agent/AgentServiceTests.cs
@@ -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
///
/// Verify that a start profiling request starts a profiling session
///
- [Fact]
+ [Test]
public async Task TestHandleAgentJobsRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
///
/// Verify that a job history request returns the job history
///
- [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())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/AssemblyInfo.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/AssemblyInfo.cs
index 70421c18..e87e98ec 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/AssemblyInfo.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/AssemblyInfo.cs
@@ -3,6 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Xunit;
+using NUnit.Framework;
-[assembly: CollectionBehavior(DisableTestParallelization = true)]
+[assembly: NonParallelizable]
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Cms/CmsServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Cms/CmsServiceTests.cs
index 615dc71d..2c8750b5 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Cms/CmsServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Cms/CmsServiceTests.cs
@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
using System;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Cms
{
@@ -37,8 +37,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Cms
return connectParams;
}
- [Fact]
- private async void TestAddCMS()
+ [Test]
+ public async Task TestAddCMS()
{
string name = "TestAddCMS" + DateTime.Now.ToString();
ConnectParams connectParams = CreateConnectParams();
@@ -63,8 +63,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Cms
requestContext.VerifyAll();
}
- [Fact]
- private async void TestAddRemoveRegisteredServer()
+ [Test]
+ public async Task TestAddRemoveRegisteredServer()
{
string name = "TestAddRemoveRegisteredServer" + DateTime.Now.ToString();
ConnectParams connectParams = await CreateAndConnectWithConnectParams();
@@ -122,8 +122,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Cms
requestContext3.VerifyAll();
}
- [Fact]
- private async void TestAddRemoveServerGroup()
+ [Test]
+ public async Task TestAddRemoveServerGroup()
{
string name = "TestAddRemoveServerGroup" + DateTime.Now.ToString();
ConnectParams connectParams = await CreateAndConnectWithConnectParams();
@@ -174,8 +174,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Cms
requestContext3.VerifyAll();
}
- [Fact]
- private async void TestAddRemoveNestedGroup()
+ [Test]
+ public async Task TestAddRemoveNestedGroup()
{
string name = "TestAddRemoveNestedGroup" + DateTime.Now.ToString();
ConnectParams connectParams = await CreateAndConnectWithConnectParams();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
index 76efb1e8..c9b3e3b4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
@@ -12,7 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
{
@@ -21,7 +21,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
public class ConnectionServiceTests
{
- [Fact]
+ [Test]
public void RunningMultipleQueriesCreatesOnlyOneConnection()
{
// Connect/disconnect twice to ensure reconnection can occur
@@ -34,8 +34,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
string uri = connectionInfo.OwnerUri;
// We should see one ConnectionInfo and one DbConnection
- Assert.Equal(1, connectionInfo.CountConnections);
- Assert.Equal(1, service.OwnerToConnectionMap.Count);
+ Assert.AreEqual(1, connectionInfo.CountConnections);
+ Assert.AreEqual(1, service.OwnerToConnectionMap.Count);
// If we run a query
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
query.ExecutionTask.Wait();
// We should see two DbConnections
- Assert.Equal(2, connectionInfo.CountConnections);
+ Assert.AreEqual(2, connectionInfo.CountConnections);
// If we run another query
query = new Query(Constants.StandardQuery, connectionInfo, new QueryExecutionSettings(), fileStreamFactory);
@@ -52,18 +52,18 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
query.ExecutionTask.Wait();
// We should still have 2 DbConnections
- Assert.Equal(2, connectionInfo.CountConnections);
+ Assert.AreEqual(2, connectionInfo.CountConnections);
// If we disconnect, we should remain in a consistent state to do it over again
// e.g. loop and do it over again
service.Disconnect(new DisconnectParams() { OwnerUri = connectionInfo.OwnerUri });
// We should be left with an empty connection map
- Assert.Equal(0, service.OwnerToConnectionMap.Count);
+ Assert.AreEqual(0, service.OwnerToConnectionMap.Count);
}
}
- [Fact]
+ [Test]
public void DatabaseChangesAffectAllConnections()
{
// If we make a connection to a live database
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
{
if (connection != null && connection.State == ConnectionState.Open)
{
- Assert.Equal(connection.Database, initialDatabaseName);
+ Assert.AreEqual(connection.Database, initialDatabaseName);
}
}
@@ -101,7 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
{
if (connection != null && connection.State == ConnectionState.Open)
{
- Assert.Equal(connection.Database, newDatabaseName);
+ Assert.AreEqual(connection.Database, newDatabaseName);
}
}
}
@@ -109,8 +109,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Test HandleGetConnectionStringRequest
///
- [Fact]
- public async void GetCurrentConnectionStringTest()
+ [Test]
+ public async Task GetCurrentConnectionStringTest()
{
// If we make a connection to a live database
ConnectionService service = ConnectionService.Instance;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ReliableConnectionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ReliableConnectionTests.cs
index fe52711e..e5a069bf 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ReliableConnectionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ReliableConnectionTests.cs
@@ -14,7 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.RetryPolicy;
using static Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.RetryPolicy.TimeBasedRetryPolicy;
using static Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.SqlSchemaModelErrorCodes;
@@ -122,7 +122,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
}
}
- [Fact]
+ [Test]
public void FixedDelayPolicyTest()
{
TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
@@ -135,7 +135,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(shouldRety);
}
- [Fact]
+ [Test]
public void FixedDelayPolicyExecuteActionTest()
{
TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
@@ -145,7 +145,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
// execute an action that throws a retry limit exception
CancellationToken token = new CancellationToken();
- Assert.Equal(policy.ExecuteAction((s) => { throw new RetryLimitExceededException(); }, token), default(int));
+ Assert.AreEqual(default(int), policy.ExecuteAction((s) => { throw new RetryLimitExceededException(); }, token));
// execute an action that throws a retry limit exeception with an inner exception
Assert.Throws(() =>
@@ -158,7 +158,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
});
}
- [Fact]
+ [Test]
public void IsRetryableExceptionTest()
{
TestFixedDelayPolicy policy = new TestFixedDelayPolicy(
@@ -169,7 +169,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.False(policy.IsRetryableException(new Exception()));
}
- [Fact]
+ [Test]
public void ProgressiveRetryPolicyTest()
{
TestProgressiveRetryPolicy policy = new TestProgressiveRetryPolicy(
@@ -184,7 +184,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.False(policy.ShouldIgnoreOnFirstTry);
}
- [Fact]
+ [Test]
public void TimeBasedRetryPolicyTest()
{
TestTimeBasedRetryPolicy policy = new TestTimeBasedRetryPolicy(
@@ -200,7 +200,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
}
- [Fact]
+ [Test]
public void GetErrorNumberWithNullExceptionTest()
{
Assert.Null(RetryPolicy.GetErrorNumber(null));
@@ -265,7 +265,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Test ReliableConnectionHelper.GetDefaultDatabaseFilePath()
///
- [Fact]
+ [Test]
public void TestGetDefaultDatabaseFilePath()
{
@@ -293,7 +293,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Test ReliableConnectionHelper.GetServerVersion()
///
- [Fact]
+ [Test]
public void TestGetServerVersion()
{
using (var connection = CreateTestConnection())
@@ -324,7 +324,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Tests ReliableConnectionHelper.GetCompleteServerName()
///
- [Fact]
+ [Test]
public void TestGetCompleteServerName()
{
string name = ReliableConnectionHelper.GetCompleteServerName(@".\SQL2008");
@@ -337,7 +337,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Tests ReliableConnectionHelper.IsDatabaseReadonly()
///
- [Fact]
+ [Test]
public void TestIsDatabaseReadonly()
{
var connectionBuilder = CreateTestConnectionStringBuilder();
@@ -350,7 +350,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// /// Tests ReliableConnectionHelper.IsDatabaseReadonly() with null builder parameter
///
- [Fact]
+ [Test]
public void TestIsDatabaseReadonlyWithNullBuilder()
{
Assert.Throws(() => ReliableConnectionHelper.IsDatabaseReadonly(null, null));
@@ -359,7 +359,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Verify ANSI_NULL and QUOTED_IDENTIFIER settings can be set and retrieved for a session
///
- [Fact]
+ [Test]
public void VerifyAnsiNullAndQuotedIdentifierSettingsReplayed()
{
using (ReliableSqlConnection conn = (ReliableSqlConnection) ReliableConnectionHelper.OpenConnection(CreateTestConnectionStringBuilder(), useRetry: true, azureAccountToken: null))
@@ -395,11 +395,11 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
AssertSessionValues(cmd, ansiNullsValue: expectedSessionValue, quotedIdentifersValue: expectedSessionValue);
// assert cached settings are correct
- Assert.Equal("ANSI_NULLS", settings[0].Item1);
- Assert.Equal(expectedSessionValue, settings[0].Item2);
+ Assert.AreEqual("ANSI_NULLS", settings[0].Item1);
+ Assert.AreEqual(expectedSessionValue, settings[0].Item2);
- Assert.Equal("QUOTED_IDENTIFIER", settings[1].Item1);
- Assert.Equal(expectedSessionValue, settings[1].Item2);
+ Assert.AreEqual("QUOTED_IDENTIFIER", settings[1].Item1);
+ Assert.AreEqual(expectedSessionValue, settings[1].Item2);
// invert session values and assert we reset them
@@ -433,8 +433,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(reader.Read(), "Missing session settings");
bool actualAnsiNullsOnValue = ((int)reader[0] == 1);
bool actualQuotedIdentifierOnValue = ((int)reader[1] == 1);
- Assert.Equal(ansiNullsValue, actualAnsiNullsOnValue);
- Assert.Equal(quotedIdentifersValue, actualQuotedIdentifierOnValue);
+ Assert.AreEqual(ansiNullsValue, actualAnsiNullsOnValue);
+ Assert.AreEqual(quotedIdentifersValue, actualQuotedIdentifierOnValue);
}
}
@@ -442,7 +442,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Test that the retry policy factory constructs all possible types of policies successfully.
///
- [Fact]
+ [Test]
public void RetryPolicyFactoryConstructsPoliciesSuccessfully()
{
RunIfWrapper.RunIfWindows(() =>
@@ -468,7 +468,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// ReliableConnectionHelper.IsCloud() should be false for a local server
///
- [Fact]
+ [Test]
public void TestIsCloudIsFalseForLocalServer()
{
using (var connection = CreateTestConnection())
@@ -483,7 +483,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Tests that ReliableConnectionHelper.OpenConnection() opens a connection if it is closed
///
- [Fact]
+ [Test]
public void TestOpenConnectionOpensConnection()
{
using (var connection = CreateTestConnection())
@@ -499,7 +499,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Tests that ReliableConnectionHelper.ExecuteNonQuery() runs successfully
///
- [Fact]
+ [Test]
public void TestExecuteNonQuery()
{
var result = ReliableConnectionHelper.ExecuteNonQuery(
@@ -516,7 +516,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Test that TryGetServerVersion() gets server information
///
- [Fact]
+ [Test]
public void TestTryGetServerVersion()
{
ReliableConnectionHelper.ServerInfo info = null;
@@ -524,14 +524,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(ReliableConnectionHelper.TryGetServerVersion(connBuilder.ConnectionString, out info, null));
Assert.NotNull(info);
- Assert.NotNull(info.ServerVersion);
- Assert.NotEmpty(info.ServerVersion);
+ Assert.That(info.ServerVersion, Is.Not.Null.Or.Empty);
}
///
/// Test that TryGetServerVersion() fails with invalid connection string
///
- [Fact]
+ [Test]
public void TestTryGetServerVersionInvalidConnectionString()
{
RunIfWrapper.RunIfWindows(() =>
@@ -544,7 +543,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Validate ambient static settings
///
- [Fact]
+ [Test]
public void AmbientSettingsStaticPropertiesTest()
{
var defaultSettings = AmbientSettings.DefaultSettings;
@@ -578,7 +577,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
///
/// Validate ambient settings populate
///
- [Fact]
+ [Test]
public void AmbientSettingsPopulateTest()
{
var data = new AmbientSettings.AmbientData();
@@ -626,7 +625,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
data.TraceSettings();
}
- [Fact]
+ [Test]
public void RaiseAmbientRetryMessageTest()
{
bool handlerCalled = false;
@@ -637,7 +636,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(handlerCalled);
}
- [Fact]
+ [Test]
public void RaiseAmbientIgnoreMessageTest()
{
bool handlerCalled = false;
@@ -648,7 +647,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(handlerCalled);
}
- [Fact]
+ [Test]
public void RetryPolicyFactoryTest()
{
Assert.NotNull(RetryPolicyFactory.NoRetryPolicy);
@@ -673,7 +672,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.False(transientPolicy.ShouldIgnoreError(new Exception()));
}
- [Fact]
+ [Test]
public void ReliableConnectionHelperTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -700,7 +699,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
}
}
- [Fact]
+ [Test]
public void DataSchemaErrorTests()
{
var error = new DataSchemaError();
@@ -722,7 +721,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.NotNull(DataSchemaError.FormatErrorCode("ex", 1));
}
- [Fact]
+ [Test]
public void InitReliableSqlConnectionTest()
{
var result = LiveConnectionHelper.InitLiveConnectionInfo();
@@ -743,7 +742,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
connection.ClearPool();
}
- [Fact]
+ [Test]
public void ThrottlingReasonTests()
{
var reason = RetryPolicy.ThrottlingReason.Unknown;
@@ -794,7 +793,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.NotNull(codeReason.ToString());
}
- [Fact]
+ [Test]
public void RetryErrorsTest()
{
var sqlServerRetryError = new SqlServerRetryError(
@@ -817,7 +816,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.True(SqlSchemaModelErrorCodes.IsStatementFilterError(StatementFilter.StatementFilterBaseCode + 1));
}
- [Fact]
+ [Test]
public void RetryCallbackEventArgsTest()
{
var exception = new Exception();
@@ -828,38 +827,38 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
// If I check the properties on the object
// Then I expect the values to be the same as the values I passed into the constructor
- Assert.Equal(5, args.RetryCount);
- Assert.Equal(exception, args.Exception);
- Assert.Equal(timespan, args.Delay);
+ Assert.AreEqual(5, args.RetryCount);
+ Assert.AreEqual(exception, args.Exception);
+ Assert.AreEqual(timespan, args.Delay);
}
- [Fact]
+ [Test]
public void CheckStaticVariables()
{
Assert.NotNull(ReliableConnectionHelper.BuilderWithDefaultApplicationName);
}
- [Fact]
+ [Test]
public void SetLockAndCommandTimeoutThrowsOnNull()
{
Assert.Throws(typeof(ArgumentNullException), () => ReliableConnectionHelper.SetLockAndCommandTimeout(null));
}
- [Fact]
+ [Test]
public void StandardExceptionHandlerTests()
{
Assert.True(ReliableConnectionHelper.StandardExceptionHandler(new InvalidCastException()));
Assert.False(ReliableConnectionHelper.StandardExceptionHandler(new Exception()));
}
- [Fact]
+ [Test]
public void GetConnectionStringBuilderNullConnectionString()
{
SqlConnectionStringBuilder builder;
Assert.False(ReliableConnectionHelper.TryGetConnectionStringBuilder(null, out builder));
}
- [Fact]
+ [Test]
public void GetConnectionStringBuilderExceptionTests()
{
SqlConnectionStringBuilder builder;
@@ -871,7 +870,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.False(ReliableConnectionHelper.TryGetConnectionStringBuilder("rabbits**frogs**lizards", out builder));
}
- [Fact]
+ [Test]
public void GetCompleteServerNameTests()
{
Assert.Null(ReliableConnectionHelper.GetCompleteServerName(null));
@@ -881,7 +880,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.NotNull(ReliableConnectionHelper.GetCompleteServerName("mytestservername"));
}
- [Fact]
+ [Test]
public void ReliableSqlCommandConstructorTests()
{
// verify default constructor doesn't throw
@@ -891,18 +890,18 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.NotNull(new ReliableSqlConnection.ReliableSqlCommand(null));
}
- [Fact]
+ [Test]
public void ReliableSqlCommandProperties()
{
var command = new ReliableSqlConnection.ReliableSqlCommand();
command.CommandText = "SELECT 1";
- Assert.Equal(command.CommandText, "SELECT 1");
+ Assert.AreEqual("SELECT 1", command.CommandText);
Assert.NotNull(command.CommandTimeout);
Assert.NotNull(command.CommandType);
command.DesignTimeVisible = true;
Assert.True(command.DesignTimeVisible);
command.UpdatedRowSource = UpdateRowSource.None;
- Assert.Equal(command.UpdatedRowSource, UpdateRowSource.None);
+ Assert.AreEqual(UpdateRowSource.None, command.UpdatedRowSource);
Assert.NotNull(command.GetUnderlyingCommand());
Assert.Throws(() => command.ValidateConnectionIsSet());
command.Prepare();
@@ -910,7 +909,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
command.Cancel();
}
- [Fact]
+ [Test]
public void ReliableConnectionResourcesTests()
{
Assert.NotNull(Resources.ConnectionPassedToIsCloudShouldBeOpen);
@@ -924,19 +923,19 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
Assert.NotNull(Resources.UnableToRetrieveAzureSessionId);
}
- [Fact]
+ [Test]
public void CalcExponentialRetryDelayWithSchemaDefaultsTest()
{
Assert.NotNull(RetryPolicyUtils.CalcExponentialRetryDelayWithSchemaDefaults(1));
}
- [Fact]
+ [Test]
public void IsSupportedCommandNullCommandTest()
{
Assert.False(DbCommandWrapper.IsSupportedCommand(null));
}
- [Fact]
+ [Test]
public void StatementCompletedTests()
{
StatementCompletedEventHandler handler = (s, e) => { };
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DacFx/DacFxserviceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DacFx/DacFxserviceTests.cs
index 4d609988..cb7e3a8b 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DacFx/DacFxserviceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DacFx/DacFxserviceTests.cs
@@ -17,8 +17,8 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.SchemaCompare.Contracts;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
+using NUnit.Framework;
using Moq;
-using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DacFx
{
@@ -71,8 +71,8 @@ RETURN 0
///
/// Verify the export bacpac request
///
- [Fact]
- public async void ExportBacpac()
+ [Test]
+ public async Task ExportBacpac()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb testdb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, null, "DacFxExportTest");
@@ -102,8 +102,8 @@ RETURN 0
///
/// Verify the import bacpac request
///
- [Fact]
- public async void ImportBacpac()
+ [Test]
+ public async Task ImportBacpac()
{
// first export a bacpac
var result = GetLiveAutoCompleteTestObjects();
@@ -150,8 +150,8 @@ RETURN 0
///
/// Verify the extract dacpac request
///
- [Fact]
- public async void ExtractDacpac()
+ [Test]
+ public async Task ExtractDacpac()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb testdb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, null, "DacFxExtractTest");
@@ -183,8 +183,8 @@ RETURN 0
///
/// Verify the extract request to create Sql file
///
- [Fact]
- public async void ExtractDBToFileTarget()
+ [Test]
+ public async Task ExtractDBToFileTarget()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb testdb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, doNotCleanupDb: false, databaseName: null, query: SourceScript, dbNamePrefix: "DacFxExtractDBToFileTarget");
@@ -217,8 +217,8 @@ RETURN 0
///
/// Verify the extract request to create a Flat file structure
///
- [Fact]
- public async void ExtractDBToFlatTarget()
+ [Test]
+ public async Task ExtractDBToFlatTarget()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb testdb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, doNotCleanupDb: false, databaseName: null, query: SourceScript, dbNamePrefix: "DacFxExtractDBToFlatTarget");
@@ -243,7 +243,7 @@ RETURN 0
// Verify two sql files are generated in the target folder path
// for dev-servers where there are more users/permissions present on server - the extract might have more files than just 2 expected tables, so check only for tables
int actualCnt = Directory.GetFiles(folderPath, "table*.sql", SearchOption.AllDirectories).Length;
- Assert.Equal(2, actualCnt);
+ Assert.AreEqual(2, actualCnt);
}
finally
{
@@ -259,8 +259,8 @@ RETURN 0
///
/// Verify the deploy dacpac request
///
- [Fact]
- public async void DeployDacpac()
+ [Test]
+ public async Task DeployDacpac()
{
// first extract a db to have a dacpac to import later
var result = GetLiveAutoCompleteTestObjects();
@@ -305,13 +305,14 @@ RETURN 0
targetDb.Cleanup();
}
}
+ return;
}
///
/// Verify the export request being cancelled
///
- [Fact]
- public async void ExportBacpacCancellationTest()
+ [Test]
+ public async Task ExportBacpacCancellationTest()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb testdb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, null, "DacFxExportTest");
@@ -353,8 +354,8 @@ RETURN 0
///
/// Verify the generate deploy script request
///
- [Fact]
- public async void GenerateDeployScript()
+ [Test]
+ public async Task GenerateDeployScript()
{
// first extract a dacpac
var result = GetLiveAutoCompleteTestObjects();
@@ -378,8 +379,8 @@ RETURN 0
service.PerformOperation(generateScriptOperation, TaskExecutionMode.Script);
// Verify script was generated
- Assert.NotEmpty(generateScriptOperation.Result.DatabaseScript);
- Assert.Contains("CREATE TABLE", generateScriptOperation.Result.DatabaseScript);
+ Assert.That(generateScriptOperation.Result.DatabaseScript, Is.Not.Empty);
+ Assert.That(generateScriptOperation.Result.DatabaseScript, Does.Contain("CREATE TABLE"));
VerifyAndCleanup(dacpacPath);
}
@@ -393,8 +394,8 @@ RETURN 0
///
/// Verify the generate deploy plan request
///
- [Fact]
- public async void GenerateDeployPlan()
+ [Test]
+ public async Task GenerateDeployPlan()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "DacFxGenerateDeployPlanTest");
@@ -418,9 +419,12 @@ RETURN 0
service.PerformOperation(generateDeployPlanOperation, TaskExecutionMode.Execute);
string report = generateDeployPlanOperation.DeployReport;
Assert.NotNull(report);
- Assert.Contains("Create", report);
- Assert.Contains("Drop", report);
- Assert.Contains("Alter", report);
+ Assert.Multiple(() =>
+ {
+ Assert.That(report, Does.Contain("Create"));
+ Assert.That(report, Does.Contain("Drop"));
+ Assert.That(report, Does.Contain("Alter"));
+ });
VerifyAndCleanup(dacpacPath);
}
@@ -437,8 +441,8 @@ RETURN 0
//
/// Verify that SqlCmdVars are set correctly for a deploy request
///
- [Fact]
- public async void DeployWithSqlCmdVariables()
+ [Test]
+ public async Task DeployWithSqlCmdVariables()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, query: storedProcScript, dbNamePrefix: "DacFxDeploySqlCmdVarsTest");
@@ -482,8 +486,8 @@ RETURN 0
}
}
- Assert.Contains(deployParams.SqlCommandVariableValues[databaseRefVarName], deployedProc);
- Assert.Contains(deployParams.SqlCommandVariableValues[filterValueVarName], deployedProc);
+ Assert.That(deployedProc, Does.Contain(deployParams.SqlCommandVariableValues[databaseRefVarName]));
+ Assert.That(deployedProc, Does.Contain(deployParams.SqlCommandVariableValues[filterValueVarName]));
VerifyAndCleanup(dacpacPath);
}
@@ -500,8 +504,8 @@ RETURN 0
//
/// Verify that SqlCmdVars are set correctly for a generate script request
///
- [Fact]
- public async void GenerateDeployScriptWithSqlCmdVariables()
+ [Test]
+ public async Task GenerateDeployScriptWithSqlCmdVariables()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, query: storedProcScript, dbNamePrefix: "DacFxGenerateScriptSqlCmdVarsTest");
@@ -528,9 +532,9 @@ RETURN 0
service.PerformOperation(generateScriptOperation, TaskExecutionMode.Script);
// Verify the SqlCmdVars were set correctly in the script
- Assert.NotEmpty(generateScriptOperation.Result.DatabaseScript);
- Assert.Contains($":setvar {databaseRefVarName} \"{generateScriptParams.SqlCommandVariableValues[databaseRefVarName]}\"", generateScriptOperation.Result.DatabaseScript);
- Assert.Contains($":setvar {filterValueVarName} \"{generateScriptParams.SqlCommandVariableValues[filterValueVarName]}\"", generateScriptOperation.Result.DatabaseScript);
+ Assert.That(generateScriptOperation.Result.DatabaseScript, Is.Not.Empty);
+ Assert.That(generateScriptOperation.Result.DatabaseScript, Does.Contain($":setvar {databaseRefVarName} \"{generateScriptParams.SqlCommandVariableValues[databaseRefVarName]}\""));
+ Assert.That(generateScriptOperation.Result.DatabaseScript, Does.Contain($":setvar {filterValueVarName} \"{generateScriptParams.SqlCommandVariableValues[filterValueVarName]}\""));
VerifyAndCleanup(dacpacPath);
}
@@ -543,8 +547,8 @@ RETURN 0
///
/// Verify that options are set correctly for a deploy request
///
- [Fact]
- public async void DeployWithOptions()
+ [Test]
+ public async Task DeployWithOptions()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, query: SourceScript, dbNamePrefix: "DacFxDeployOptionsTestSource");
@@ -607,10 +611,10 @@ RETURN 0
{
await conn.OpenAsync();
var deployedResult = (string)ReliableConnectionHelper.ExecuteScalar(conn, $"SELECT TABLE_NAME FROM {targetDb.DatabaseName}.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'table3'; ");
- Assert.Equal(expectedTableResult, deployedResult);
+ Assert.AreEqual(expectedTableResult, deployedResult);
deployedResult = (string)ReliableConnectionHelper.ExecuteScalar(conn, $"SELECT TABLE_NAME FROM {targetDb.DatabaseName}.INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'view1'; ");
- Assert.Equal(expectedViewResult, deployedResult);
+ Assert.AreEqual(expectedViewResult, deployedResult);
}
finally
{
@@ -622,8 +626,8 @@ RETURN 0
//
/// Verify that options are set correctly for a generate script request
///
- [Fact]
- public async void GenerateDeployScriptWithOptions()
+ [Test]
+ public async Task GenerateDeployScriptWithOptions()
{
var result = GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, query: SourceScript, dbNamePrefix: "DacFxDeployOptionsTestSource");
@@ -651,8 +655,8 @@ RETURN 0
var generateScriptFalseOptionOperation = new GenerateDeployScriptOperation(generateScriptFalseOptionParams, result.ConnectionInfo);
service.PerformOperation(generateScriptFalseOptionOperation, TaskExecutionMode.Execute);
- Assert.DoesNotContain("table3", generateScriptFalseOptionOperation.Result.DatabaseScript);
- Assert.DoesNotContain("CREATE VIEW", generateScriptFalseOptionOperation.Result.DatabaseScript);
+ Assert.That(generateScriptFalseOptionOperation.Result.DatabaseScript, Does.Not.Contain("table3"));
+ Assert.That(generateScriptFalseOptionOperation.Result.DatabaseScript, Does.Not.Contain("CREATE VIEW"));
// try to deploy with the option set to true to make sure it works
var generateScriptTrueOptionParams = new GenerateDeployScriptParams
@@ -669,8 +673,8 @@ RETURN 0
var generateScriptTrueOptionOperation = new GenerateDeployScriptOperation(generateScriptTrueOptionParams, result.ConnectionInfo);
service.PerformOperation(generateScriptTrueOptionOperation, TaskExecutionMode.Execute);
- Assert.Contains("DROP TABLE [dbo].[table3]", generateScriptTrueOptionOperation.Result.DatabaseScript);
- Assert.DoesNotContain("CREATE VIEW", generateScriptTrueOptionOperation.Result.DatabaseScript);
+ Assert.That(generateScriptTrueOptionOperation.Result.DatabaseScript, Does.Contain("DROP TABLE [dbo].[table3]"));
+ Assert.That(generateScriptTrueOptionOperation.Result.DatabaseScript, Does.Not.Contain("CREATE VIEW"));
// now generate script without options
var generateScriptNoOptionsParams = new GenerateDeployScriptParams
@@ -682,8 +686,8 @@ RETURN 0
var generateScriptNoOptionsOperation = new GenerateDeployScriptOperation(generateScriptNoOptionsParams, result.ConnectionInfo);
service.PerformOperation(generateScriptNoOptionsOperation, TaskExecutionMode.Execute);
- Assert.Contains("table3", generateScriptNoOptionsOperation.Result.DatabaseScript);
- Assert.Contains("CREATE VIEW", generateScriptNoOptionsOperation.Result.DatabaseScript);
+ Assert.That(generateScriptNoOptionsOperation.Result.DatabaseScript, Does.Contain("table3"));
+ Assert.That(generateScriptNoOptionsOperation.Result.DatabaseScript, Does.Contain("CREATE VIEW"));
VerifyAndCleanup(dacpacPath);
}
@@ -700,8 +704,8 @@ RETURN 0
//
/// Verify that options can get retrieved from publish profile
///
- [Fact]
- public async void GetOptionsFromProfile()
+ [Test]
+ public async Task GetOptionsFromProfile()
{
DeploymentOptions expectedResults = new DeploymentOptions()
{
@@ -729,8 +733,8 @@ RETURN 0
//
/// Verify that default options are returned if a profile doesn't specify any options
///
- [Fact]
- public async void GetOptionsFromProfileWithoutOptions()
+ [Test]
+ public async Task GetOptionsFromProfileWithoutOptions()
{
DeploymentOptions expectedResults = new DeploymentOptions();
expectedResults.ExcludeObjectTypes = null;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
index bc044b62..b15cfb7b 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
@@ -22,7 +22,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
@@ -42,8 +42,8 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
/// Get backup configuration info
///
/// Test is failing in code coverage runs. Reenable when stable.
- ///[Fact]
- public async void GetBackupConfigInfoTest()
+ ///[Test]
+ public async Task GetBackupConfigInfoTest()
{
string databaseName = "testbackup_" + new Random().Next(10000000, 99999999);
using (SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName))
@@ -72,7 +72,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
///
/// Create simple backup test
///
- [Fact]
+ [Test]
public void CreateBackupTest()
{
DisasterRecoveryService service = new DisasterRecoveryService();
@@ -100,7 +100,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
}
}
- [Fact]
+ [Test]
public void ScriptBackupTest()
{
DisasterRecoveryService service = new DisasterRecoveryService();
@@ -137,7 +137,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
///
/// Test creating backup with advanced options set.
///
- [Fact]
+ [Test]
public void CreateBackupWithAdvancedOptionsTest()
{
DisasterRecoveryService service = new DisasterRecoveryService();
@@ -190,7 +190,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
///
/// Test creating backup with advanced options set.
///
- [Fact]
+ [Test]
public void ScriptBackupWithAdvancedOptionsTest()
{
DisasterRecoveryService service = new DisasterRecoveryService();
@@ -245,7 +245,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
///
/// Test the correct script generation for different backup action types
///
- [Fact]
+ [Test]
public void ScriptBackupWithDifferentActionTypesTest()
{
string databaseName = "SqlToolsService_TestBackup_" + new Random().Next(10000000, 99999999);
@@ -255,30 +255,30 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
string script = GenerateScriptForBackupType(BackupType.Full, databaseName);
// Validate Full backup script
- Assert.Contains("BACKUP DATABASE", script, StringComparison.OrdinalIgnoreCase);
- Assert.DoesNotContain("BACKUP LOG", script, StringComparison.OrdinalIgnoreCase);
- Assert.DoesNotContain("DIFFERENTIAL", script, StringComparison.OrdinalIgnoreCase);
+ Assert.That(script, Does.Contain("BACKUP DATABASE").IgnoreCase);
+ Assert.That(script, Does.Not.Contain("BACKUP LOG").IgnoreCase);
+ Assert.That(script, Does.Not.Contain("DIFFERENTIAL").IgnoreCase);
// Create log backup script
script = GenerateScriptForBackupType(BackupType.TransactionLog, databaseName);
// Validate Log backup script
- Assert.Contains("BACKUP LOG", script, StringComparison.OrdinalIgnoreCase);
- Assert.DoesNotContain("BACKUP DATABASE", script, StringComparison.OrdinalIgnoreCase);
- Assert.DoesNotContain("DIFFERENTIAL", script, StringComparison.OrdinalIgnoreCase);
+ Assert.That(script, Does.Contain("BACKUP LOG").IgnoreCase);
+ Assert.That(script, Does.Not.Contain("BACKUP DATABASE").IgnoreCase);
+ Assert.That(script, Does.Not.Contain("DIFFERENTIAL").IgnoreCase);
// Create differential backup script
script = GenerateScriptForBackupType(BackupType.Differential, databaseName);
// Validate differential backup script
- Assert.Contains("BACKUP DATABASE", script, StringComparison.OrdinalIgnoreCase);
- Assert.DoesNotContain("BACKUP LOG", script, StringComparison.OrdinalIgnoreCase);
- Assert.Contains("WITH DIFFERENTIAL", script, StringComparison.OrdinalIgnoreCase);
+ Assert.That(script, Does.Contain("BACKUP DATABASE").IgnoreCase);
+ Assert.That(script, Does.Not.Contain("BACKUP LOG").IgnoreCase);
+ Assert.That(script, Does.Contain("WITH DIFFERENTIAL").IgnoreCase);
}
}
- //[Fact]
- public async void BackupFileBrowserTest()
+ //[Test]
+ public async Task BackupFileBrowserTest()
{
string databaseName = "testfilebrowser_" + new Random().Next(10000000, 99999999);
SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/DisasterRecoveryFileValidatorTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/DisasterRecoveryFileValidatorTests.cs
index 9790426e..167666fc 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/DisasterRecoveryFileValidatorTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/DisasterRecoveryFileValidatorTests.cs
@@ -13,7 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Management;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
@@ -22,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
///
public class DisasterRecoveryFileValidatorTests
{
- [Fact]
+ [Test]
public void ValidateDefaultBackupFullFilePath()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
@@ -39,10 +39,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}, out message);
Assert.True(result);
- Assert.Empty(message);
+ Assert.That(message, Is.Empty);
}
- [Fact]
+ [Test]
public void ValidateDefaultBackupFolderPath()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
Assert.True(result);
}
- //[Fact]
+ //[Test]
public void ValidatorShouldReturnFalseForInvalidPath()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/RestoreDatabaseServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/RestoreDatabaseServiceTests.cs
index 2564bf8e..90df9378 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/RestoreDatabaseServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/RestoreDatabaseServiceTests.cs
@@ -23,7 +23,7 @@ using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests;
using Moq;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
@@ -65,16 +65,16 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
return backupFilesToRecoverDatabase;
}
- [Fact]
- public async void RestorePlanShouldCreatedSuccessfullyForFullBackup()
+ [Test]
+ public async Task RestorePlanShouldCreatedSuccessfullyForFullBackup()
{
await VerifyBackupFileCreated();
bool canRestore = true;
await VerifyRestore(fullBackupFilePath, canRestore);
}
- [Fact]
- public async void RestoreShouldNotRestoreAnyBackupSetsIfFullNotSelected()
+ [Test]
+ public async Task RestoreShouldNotRestoreAnyBackupSetsIfFullNotSelected()
{
var backupFiles = await GetBackupFilesToRecoverDatabaseCreated();
//Remove the full backupset
@@ -85,8 +85,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
await VerifyRestoreMultipleBackupSets(backupFiles, indexToDelete, expectedTable, TaskExecutionModeFlag.Execute);
}
- [Fact]
- public async void RestoreShouldRestoreFromAnotherDatabase()
+ [Test]
+ public async Task RestoreShouldRestoreFromAnotherDatabase()
{
await GetBackupFilesToRecoverDatabaseCreated();
@@ -106,8 +106,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestoreShouldFailIfThereAreOtherConnectionsToDatabase()
+ [Test]
+ public async Task RestoreShouldFailIfThereAreOtherConnectionsToDatabase()
{
await GetBackupFilesToRecoverDatabaseCreated();
@@ -138,8 +138,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestoreShouldFailIfThereAreOtherConnectionsToDatabase2()
+ [Test]
+ public async Task RestoreShouldFailIfThereAreOtherConnectionsToDatabase2()
{
await GetBackupFilesToRecoverDatabaseCreated();
@@ -173,8 +173,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestoreShouldCloseOtherConnectionsBeforeExecuting()
+ [Test]
+ public async Task RestoreShouldCloseOtherConnectionsBeforeExecuting()
{
await GetBackupFilesToRecoverDatabaseCreated();
@@ -213,8 +213,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestoreShouldRestoreTheBackupSetsThatAreSelected()
+ [Test]
+ public async Task RestoreShouldRestoreTheBackupSetsThatAreSelected()
{
var backupFiles = await GetBackupFilesToRecoverDatabaseCreated();
//Remove the last backupset
@@ -225,8 +225,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
await VerifyRestoreMultipleBackupSets(backupFiles, indexToDelete, expectedTable);
}
- [Fact]
- public async void RestoreShouldNotRestoreTheLogBackupSetsIfOneNotSelected()
+ [Test]
+ public async Task RestoreShouldNotRestoreTheLogBackupSetsIfOneNotSelected()
{
var backupFiles = await GetBackupFilesToRecoverDatabaseCreated();
//Remove the one of the log backup sets
@@ -276,7 +276,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
for (int i = 0; i < response.BackupSetsToRestore.Count(); i++)
{
DatabaseFileInfo databaseInfo = response.BackupSetsToRestore[i];
- Assert.Equal(databaseInfo.IsSelected, expectedSelectedIndexes.Contains(i));
+ Assert.AreEqual(databaseInfo.IsSelected, expectedSelectedIndexes.Contains(i));
}
}
finally
@@ -288,8 +288,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestorePlanShouldCreatedSuccessfullyOnExistingDatabaseGivenReplaceOption()
+ [Test]
+ public async Task RestorePlanShouldCreatedSuccessfullyOnExistingDatabaseGivenReplaceOption()
{
SqlTestDb testDb = null;
try
@@ -312,8 +312,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestorePlanShouldFailOnExistingDatabaseNotGivenReplaceOption()
+ [Test]
+ public async Task RestorePlanShouldFailOnExistingDatabaseNotGivenReplaceOption()
{
SqlTestDb testDb = null;
try
@@ -334,8 +334,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- //[Fact]
- public async void RestoreShouldCreatedSuccessfullyGivenTwoBackupFiles()
+ //[Test]
+ public async Task RestoreShouldCreatedSuccessfullyGivenTwoBackupFiles()
{
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
@@ -344,8 +344,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
Assert.True(response.BackupSetsToRestore.Count() == 2);
}
- //[Fact]
- public async void RestoreShouldFailGivenTwoBackupFilesButFilterFullBackup()
+ //[Test]
+ public async Task RestoreShouldFailGivenTwoBackupFilesButFilterFullBackup()
{
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
@@ -360,8 +360,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- //[Fact]
- public async void RestoreShouldCompletedSuccessfullyGivenTwoBackupFilesButFilterDifferentialBackup()
+ //[Test]
+ public async Task RestoreShouldCompletedSuccessfullyGivenTwoBackupFilesButFilterDifferentialBackup()
{
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
@@ -376,8 +376,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
- public async void RestoreShouldExecuteSuccessfullyForFullBackup()
+ [Test]
+ public async Task RestoreShouldExecuteSuccessfullyForFullBackup()
{
await VerifyBackupFileCreated();
@@ -387,8 +387,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
Assert.NotNull(restorePlan.BackupSetsToRestore);
}
- [Fact]
- public async void RestoreToAnotherDatabaseShouldExecuteSuccessfullyForFullBackup()
+ [Test]
+ public async Task RestoreToAnotherDatabaseShouldExecuteSuccessfullyForFullBackup()
{
await VerifyBackupFileCreated();
@@ -397,23 +397,23 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
var restorePlan = await VerifyRestore(backupFileName, canRestore, TaskExecutionModeFlag.ExecuteAndScript, "NewRestoredDatabase");
}
- //[Fact]
- public async void RestorePlanShouldCreatedSuccessfullyForDiffBackup()
+ //[Test]
+ public async Task RestorePlanShouldCreatedSuccessfullyForDiffBackup()
{
string backupFileName = "DiffBackup.bak";
bool canRestore = true;
await VerifyRestore(backupFileName, canRestore);
}
- //[Fact]
- public async void RestorePlanShouldCreatedSuccessfullyForTransactionLogBackup()
+ //[Test]
+ public async Task RestorePlanShouldCreatedSuccessfullyForTransactionLogBackup()
{
string backupFileName = "TransactionLogBackup.bak";
bool canRestore = true;
await VerifyRestore(backupFileName, canRestore);
}
- [Fact]
+ [Test]
public async Task RestorePlanRequestShouldReturnResponseWithDbFiles()
{
await VerifyBackupFileCreated();
@@ -439,7 +439,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
+ [Test]
public async Task CancelRestorePlanRequestShouldCancelSuccessfully()
{
await VerifyBackupFileCreated();
@@ -473,7 +473,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
+ [Test]
public async Task RestoreConfigInfoRequestShouldReturnResponse()
{
await VerifyBackupFileCreated();
@@ -499,7 +499,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
+ [Test]
public async Task RestoreDatabaseRequestShouldStartTheRestoreTask()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -526,7 +526,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
}
}
- [Fact]
+ [Test]
public async Task RestorePlanRequestShouldReturnErrorMessageGivenInvalidFilePath()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -625,7 +625,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
Assert.NotNull(response);
Assert.False(string.IsNullOrWhiteSpace(response.SessionId));
- Assert.Equal(response.CanRestore, canRestore);
+ Assert.AreEqual(response.CanRestore, canRestore);
if (canRestore)
{
Assert.True(response.DbFiles.Any());
@@ -633,7 +633,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
targetDatabase = response.DatabaseName;
}
- Assert.Equal(response.DatabaseName, targetDatabase);
+ Assert.AreEqual(response.DatabaseName, targetDatabase);
Assert.NotNull(response.PlanDetails);
Assert.True(response.PlanDetails.Any());
Assert.NotNull(response.PlanDetails[RestoreOptionsHelper.BackupTailLog]);
@@ -649,7 +649,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
request.SessionId = response.SessionId;
restoreDataObject = service.CreateRestoreDatabaseTaskDataObject(request);
- Assert.Equal(response.SessionId, restoreDataObject.SessionId);
+ Assert.AreEqual(response.SessionId, restoreDataObject.SessionId);
request.RelocateDbFiles = !restoreDataObject.DbFilesLocationAreValid();
restoreDataObject.Execute((TaskExecutionMode)Enum.Parse(typeof(TaskExecutionMode), executionMode.ToString()));
@@ -666,7 +666,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
//Some tests still verify the number of backup sets that are executed which in some cases can be less than the selected list
if (verifyDatabase == null && selectedBackupSets != null)
{
- Assert.Equal(selectedBackupSets.Count(), restoreDataObject.RestorePlanToExecute.RestoreOperations.Count());
+ Assert.AreEqual(selectedBackupSets.Count(), restoreDataObject.RestorePlanToExecute.RestoreOperations.Count());
}
}
if(executionMode.HasFlag(TaskExecutionModeFlag.Script))
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/FileBrowser/FileBrowserServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/FileBrowser/FileBrowserServiceTests.cs
index 4193e094..b93639cb 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/FileBrowser/FileBrowserServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/FileBrowser/FileBrowserServiceTests.cs
@@ -10,7 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.FileBrowser.Contracts;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
{
@@ -21,8 +21,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
{
#region Request handle tests
- [Fact]
- public async void HandleFileBrowserOpenRequestTest()
+ [Test]
+ public async Task HandleFileBrowserOpenRequestTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -41,8 +41,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
openRequestContext.Verify(x => x.SendResult(It.Is(p => p == true)));
}
- [Fact]
- public async void HandleFileBrowserExpandRequestTest()
+ [Test]
+ public async Task HandleFileBrowserExpandRequestTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -59,8 +59,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
requestContext.Verify(x => x.SendResult(It.Is(p => p == true)));
}
- [Fact]
- public async void HandleFileBrowserValidateRequestTest()
+ [Test]
+ public async Task HandleFileBrowserValidateRequestTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -77,8 +77,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
requestContext.Verify(x => x.SendResult(It.Is(p => p == true)));
}
- [Fact]
- public async void HandleFileBrowserCloseRequestTest()
+ [Test]
+ public async Task HandleFileBrowserCloseRequestTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -96,8 +96,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
#endregion
- [Fact]
- public async void OpenFileBrowserTest()
+ [Test]
+ public async Task OpenFileBrowserTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -123,8 +123,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
efv.Validate();
}
- [Fact]
- public async void ValidateSelectedFilesWithNullValidatorTest()
+ [Test]
+ public async Task ValidateSelectedFilesWithNullValidatorTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo();
FileBrowserService service = new FileBrowserService();
@@ -146,8 +146,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.FileBrowser
efv.Validate();
}
- [Fact]
- public async void InvalidFileValidationTest()
+ [Test]
+ public async Task InvalidFileValidationTest()
{
FileBrowserService service = new FileBrowserService();
service.RegisterValidatePathsCallback("TestService", ValidatePaths);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageExtensibility/ExternalLanguageServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageExtensibility/ExternalLanguageServiceTests.cs
index ceb82afc..3631f5e4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageExtensibility/ExternalLanguageServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageExtensibility/ExternalLanguageServiceTests.cs
@@ -17,15 +17,15 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
{
public class ExternalLanguageServiceTests : ServiceTestBase
{
- [Fact]
- public async void VerifyExternalLanguageStatusRequest()
+ [Test]
+ public async Task VerifyExternalLanguageStatusRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -50,8 +50,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
}
}
- [Fact]
- public async void VerifyExternalLanguageDeleteRequest()
+ [Test]
+ public async Task VerifyExternalLanguageDeleteRequest()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -80,8 +80,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
}));
}
- [Fact]
- public async void VerifyExternalLanguageDeleteRequestFailures()
+ [Test]
+ public async Task VerifyExternalLanguageDeleteRequestFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -106,8 +106,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
});
}
- [Fact]
- public async void VerifyExternalLanguageDeleteRequestConnectionFailures()
+ [Test]
+ public async Task VerifyExternalLanguageDeleteRequestConnectionFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -131,8 +131,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
});
}
- [Fact]
- public async void VerifyExternalLanguageUpdateRequest()
+ [Test]
+ public async Task VerifyExternalLanguageUpdateRequest()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -161,8 +161,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
}));
}
- [Fact]
- public async void VerifyExternalLanguageUpdateRequestFailures()
+ [Test]
+ public async Task VerifyExternalLanguageUpdateRequestFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -187,8 +187,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
});
}
- [Fact]
- public async void VerifyExternalLanguageUpdateRequestConnectionFailures()
+ [Test]
+ public async Task VerifyExternalLanguageUpdateRequestConnectionFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -212,8 +212,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
});
}
- [Fact]
- public async void VerifyExternalLanguageListRequest()
+ [Test]
+ public async Task VerifyExternalLanguageListRequest()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -241,8 +241,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
}));
}
- [Fact]
- public async void VerifyExternalLanguagListRequestFailures()
+ [Test]
+ public async Task VerifyExternalLanguagListRequestFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -266,8 +266,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
});
}
- [Fact]
- public async void VerifyExternalLanguagListRequestConnectionFailures()
+ [Test]
+ public async Task VerifyExternalLanguagListRequestConnectionFailures()
{
ExternalLanguage language = new ExternalLanguage
{
@@ -323,8 +323,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageExtensibility
}
}
- [Fact]
- public async void VerifyExternalLanguageStatusRequestSendErrorGivenInvalidConnection()
+ [Test]
+ public async Task VerifyExternalLanguageStatusRequestSendErrorGivenInvalidConnection()
{
ExternalLanguageStatusResponseParams result = null;
var requestContext = RequestContextMocks.Create(r => result = r).AddErrorHandling(null);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/LanguageServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/LanguageServiceTests.cs
index 7ad16dea..79b3b868 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/LanguageServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/LanguageServiceTests.cs
@@ -22,7 +22,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
{
@@ -51,7 +51,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
///
/// Test the service initialization code path and verify nothing throws
///
- [Fact]
+ [Test]
public void ServiceInitialization()
{
try
@@ -72,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
///
/// Test the service initialization code path and verify nothing throws
///
- //[Fact]
+ //[Test]
public void PrepopulateCommonMetadata()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -89,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
///
/// This test tests auto completion
///
- [Fact]
+ [Test]
public void AutoCompleteFindCompletions()
{
var result = GetLiveAutoCompleteTestObjects();
@@ -123,8 +123,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
/// 2. Initializing a completion extension implementation
/// 3. Excuting an auto completion with extension enabled
///
- [Fact]
- public async void AutoCompleteWithExtension()
+ [Test]
+ public async Task AutoCompleteWithExtension()
{
var result = GetLiveAutoCompleteTestObjects();
@@ -217,7 +217,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
/// has an associated ScriptParseInfo and the provided query has a function that should
/// provide signature help.
///
- [Fact]
+ [Test]
public async Task GetSignatureHelpReturnsNotNullIfParseInfoInitialized()
{
// When we make a connection to a live database
@@ -257,7 +257,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
///
/// Test overwriting the binding queue context
///
- [Fact]
+ [Test]
public void OverwriteBindingContext()
{
var result = LiveConnectionHelper.InitLiveConnectionInfo();
@@ -279,7 +279,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
///
/// Verifies that clearing the Intellisense cache correctly refreshes the cache with new info from the DB.
///
- [Fact]
+ [Test]
public async Task RebuildIntellisenseCacheClearsScriptParseInfoCorrectly()
{
var testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, null, null, "LangSvcTest");
@@ -338,7 +338,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.LanguageServer
// This test validates switching off editor intellisesnse for now.
// Will change to better handling once we have specific SQLCMD intellisense in Language Service
///
- [Fact]
+ [Test]
public async Task HandleRequestToChangeToSqlcmdFile()
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs
index c3bd6041..2eec3a64 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs
@@ -15,7 +15,7 @@ using System;
using System.Data.Common;
using System.IO;
using System.Threading;
-using Xunit;
+using NUnit.Framework;
using ConnectionType = Microsoft.SqlTools.ServiceLayer.Connection.ConnectionType;
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
using System.Collections.Generic;
@@ -86,7 +86,7 @@ GO";
///
/// Test get definition for a table object with active connection
///
- [Fact]
+ [Test]
public void GetValidTableDefinitionTest()
{
// Get live connectionInfo and serverConnection
@@ -105,7 +105,7 @@ GO";
Cleanup(locations);
}
- [Fact]
+ [Test]
public void LoggerGetValidTableDefinitionTest()
{
TestLogger test = new TestLogger()
@@ -126,7 +126,7 @@ GO";
///
/// Test get definition for a invalid table object with active connection
///
- [Fact]
+ [Test]
public void GetTableDefinitionInvalidObjectTest()
{
// Get live connectionInfo and serverConnection
@@ -146,7 +146,7 @@ GO";
///
/// Test get definition for a valid table object with schema and active connection
///
- [Fact]
+ [Test]
public void GetTableDefinitionWithSchemaTest()
{
// Get live connectionInfo and serverConnection
@@ -168,7 +168,7 @@ GO";
///
/// Test GetDefinition with an unsupported type(schema - dbo). Expect a error result.
///
- [Fact]
+ [Test]
public void GetUnsupportedDefinitionErrorTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -187,7 +187,7 @@ GO";
///
/// Get Definition for a object with no definition. Expect a error result
///
- [Fact]
+ [Test]
public void GetDefinitionWithNoResultsFoundError()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -206,13 +206,13 @@ GO";
Assert.NotNull(result);
Assert.True(result.IsErrorResult);
- Assert.Equal(SR.PeekDefinitionNoResultsError, result.Message);
+ Assert.AreEqual(SR.PeekDefinitionNoResultsError, result.Message);
}
///
/// Test GetDefinition with a forced timeout. Expect a error result.
///
- [Fact]
+ [Test]
public void GetDefinitionTimeoutTest()
{
// Given a binding queue that will automatically time out
@@ -268,13 +268,13 @@ GO";
Assert.NotNull(result);
Assert.True(result.IsErrorResult);
// Check timeout message
- Assert.Equal(SR.PeekDefinitionTimedoutError, result.Message);
+ Assert.AreEqual(SR.PeekDefinitionTimedoutError, result.Message);
}
///
/// Test get definition for a view object with active connection
///
- [Fact]
+ [Test]
public void GetValidViewDefinitionTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -293,7 +293,7 @@ GO";
///
/// Test get definition for an invalid view object with no schema name and with active connection
///
- [Fact]
+ [Test]
public void GetViewDefinitionInvalidObjectTest()
{
// Get live connectionInfo and serverConnection
@@ -312,7 +312,7 @@ GO";
///
/// Test get definition for a stored procedure object with active connection
///
- [Fact]
+ [Test]
public void GetStoredProcedureDefinitionTest()
{
// Get live connectionInfo and serverConnection
@@ -333,7 +333,7 @@ GO";
///
/// Test get definition for a stored procedure object that does not exist with active connection
///
- [Fact]
+ [Test]
public void GetStoredProcedureDefinitionFailureTest()
{
// Get live connectionInfo and serverConnection
@@ -352,7 +352,7 @@ GO";
///
/// Test get definition for a stored procedure object with active connection and no schema
///
- [Fact]
+ [Test]
public void GetStoredProcedureDefinitionWithoutSchemaTest()
{
// Get live connectionInfo and serverConnection
@@ -372,7 +372,7 @@ GO";
///
/// Test get definition for a scalar valued function object with active connection and explicit schema name. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetScalarValuedFunctionDefinitionWithSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(AddTwoFunctionQuery, AddTwoFunctionName, ScalarValuedFunctionTypeName);
@@ -421,7 +421,7 @@ GO";
///
/// Test get definition for a table valued function object with active connection and explicit schema name. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetTableValuedFunctionDefinitionWithSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(ReturnTableTableFunctionQuery, ReturnTableFunctionName, ScalarValuedFunctionTypeName);
@@ -430,7 +430,7 @@ GO";
///
/// Test get definition for a scalar valued function object that doesn't exist with active connection. Expect null locations
///
- [Fact]
+ [Test]
public async Task GetScalarValuedFunctionDefinitionWithNonExistentFailureTest()
{
string objectName = "doesNotExist";
@@ -443,7 +443,7 @@ GO";
///
/// Test get definition for a table valued function object that doesn't exist with active connection. Expect null locations
///
- [Fact]
+ [Test]
public async Task GetTableValuedFunctionDefinitionWithNonExistentObjectFailureTest()
{
string objectName = "doesNotExist";
@@ -455,7 +455,7 @@ GO";
///
/// Test get definition for a scalar valued function object with active connection. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetScalarValuedFunctionDefinitionWithoutSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(AddTwoFunctionQuery, AddTwoFunctionName, ScalarValuedFunctionTypeName, null);
@@ -464,7 +464,7 @@ GO";
///
/// Test get definition for a table valued function object with active connection. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetTableValuedFunctionDefinitionWithoutSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(ReturnTableTableFunctionQuery, ReturnTableFunctionName, ScalarValuedFunctionTypeName, null);
@@ -474,7 +474,7 @@ GO";
///
/// Test get definition for a user defined data type object with active connection and explicit schema name. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedDataTypeDefinitionWithSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(SsnTypeQuery, SsnTypeName, UserDefinedDataTypeTypeName);
@@ -483,7 +483,7 @@ GO";
///
/// Test get definition for a user defined data type object with active connection. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedDataTypeDefinitionWithoutSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(SsnTypeQuery, SsnTypeName, UserDefinedDataTypeTypeName, null);
@@ -492,7 +492,7 @@ GO";
///
/// Test get definition for a user defined data type object that doesn't exist with active connection. Expect null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedDataTypeDefinitionWithNonExistentFailureTest()
{
string objectName = "doesNotExist";
@@ -504,7 +504,7 @@ GO";
///
/// Test get definition for a user defined table type object with active connection and explicit schema name. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedTableTypeDefinitionWithSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(LocationTableTypeQuery, LocationTableTypeName, UserDefinedTableTypeTypeName);
@@ -513,7 +513,7 @@ GO";
///
/// Test get definition for a user defined table type object with active connection. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedTableTypeDefinitionWithoutSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(LocationTableTypeQuery, LocationTableTypeName, UserDefinedTableTypeTypeName, null);
@@ -522,7 +522,7 @@ GO";
///
/// Test get definition for a user defined table type object that doesn't exist with active connection. Expect null locations
///
- [Fact]
+ [Test]
public async Task GetUserDefinedTableTypeDefinitionWithNonExistentFailureTest()
{
string objectName = "doesNotExist";
@@ -535,7 +535,7 @@ GO";
///
/// Test get definition for a synonym object with active connection and explicit schema name. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetSynonymDefinitionWithSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(TestTableSynonymQuery, TestTableSynonymName, SynonymTypeName);
@@ -545,7 +545,7 @@ GO";
///
/// Test get definition for a Synonym object with active connection. Expect non-null locations
///
- [Fact]
+ [Test]
public async Task GetSynonymDefinitionWithoutSchemaNameSuccessTest()
{
await ExecuteAndValidatePeekTest(TestTableSynonymQuery, TestTableSynonymName, SynonymTypeName, null);
@@ -554,7 +554,7 @@ GO";
///
/// Test get definition for a Synonym object that doesn't exist with active connection. Expect null locations
///
- [Fact]
+ [Test]
public async Task GetSynonymDefinitionWithNonExistentFailureTest()
{
string objectName = "doesNotExist";
@@ -567,7 +567,7 @@ GO";
/// Test get definition using declaration type for a view object with active connection
/// Expect a non-null result with location
///
- [Fact]
+ [Test]
public void GetDefinitionUsingDeclarationTypeWithValidObjectTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -589,7 +589,7 @@ GO";
/// Test get definition using declaration type for a non existent view object with active connection
/// Expect a non-null result with location
///
- [Fact]
+ [Test]
public void GetDefinitionUsingDeclarationTypeWithNonexistentObjectTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -608,7 +608,7 @@ GO";
/// Test get definition using quickInfo text for a view object with active connection
/// Expect a non-null result with location
///
- [Fact]
+ [Test]
public void GetDefinitionUsingQuickInfoTextWithValidObjectTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -631,7 +631,7 @@ GO";
/// Test get definition using quickInfo text for a view object with active connection
/// Expect a non-null result with location
///
- [Fact]
+ [Test]
public void GetDefinitionUsingQuickInfoTextWithNonexistentObjectTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -652,7 +652,7 @@ GO";
/// Given that there is no query connection
/// Expect database name to be "master"
///
- [Fact]
+ [Test]
public void GetDatabaseWithNoQueryConnectionTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -663,7 +663,7 @@ GO";
Scripter scripter = new Scripter(serverConnection, connInfo);
//Check if database name is the default server connection database name
- Assert.Equal(scripter.Database.Name, "master");
+ Assert.AreEqual("master", scripter.Database.Name);
}
///
@@ -671,7 +671,7 @@ GO";
/// Give that there is a query connection
/// Expect database name to be query connection's database name
///
- [Fact]
+ [Test]
public void GetDatabaseWithQueryConnectionTest()
{
ConnectionInfo connInfo = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
@@ -686,7 +686,7 @@ GO";
Scripter scripter = new Scripter(serverConnection, connInfo);
//Check if database name is the database name in the query connection
- Assert.Equal(scripter.Database.Name, "testdb");
+ Assert.AreEqual("testdb", scripter.Database.Name);
// remove mock from ConnectionInfo
Assert.True(connInfo.ConnectionTypeToConnectionMap.TryRemove(ConnectionType.Query, out connection));
@@ -698,8 +698,8 @@ GO";
/// Get Definition for a object by putting the cursor on 3 different
/// objects
///
- [Fact]
- public async void GetDefinitionFromChildrenAndParents()
+ [Test]
+ public async Task GetDefinitionFromChildrenAndParents()
{
string queryString = "select * from master.sys.objects";
// place the cursor on every token
@@ -743,8 +743,8 @@ GO";
Assert.NotNull(masterResult);
// And I expect the all results to be the same
- Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations));
- Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations));
+ Assert.That(objectResult.Locations, Is.EqualTo(sysResult.Locations), "objectResult and sysResult Locations");
+ Assert.That(objectResult.Locations, Is.EqualTo(masterResult.Locations), "objectResult and masterResult Locations");
Cleanup(objectResult.Locations);
Cleanup(sysResult.Locations);
@@ -753,8 +753,8 @@ GO";
connInfo.RemoveAllConnections();
}
- [Fact]
- public async void GetDefinitionFromProcedures()
+ [Test]
+ public async Task GetDefinitionFromProcedures()
{
string queryString = "EXEC master.dbo.sp_MSrepl_startup";
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Metadata/MetadataServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Metadata/MetadataServiceTests.cs
index 89da35f3..79246398 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Metadata/MetadataServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Metadata/MetadataServiceTests.cs
@@ -17,7 +17,7 @@ using Microsoft.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
@@ -70,7 +70,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
///
/// Verify that the metadata service correctly returns details for user tables
///
- [Fact]
+ [Test]
public void MetadataReturnsUserTable()
{
this.testTableName += new Random().Next(1000000, 9999999).ToString();
@@ -100,8 +100,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
DeleteTestTable(sqlConn);
}
- [Fact]
- public async void GetTableInfoReturnsValidResults()
+ [Test]
+ public async Task GetTableInfoReturnsValidResults()
{
this.testTableName += new Random().Next(1000000, 9999999).ToString();
@@ -127,8 +127,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
requestContext.VerifyAll();
}
- [Fact]
- public async void GetViewInfoReturnsValidResults()
+ [Test]
+ public async Task GetViewInfoReturnsValidResults()
{
var result = GetLiveAutoCompleteTestObjects();
var requestContext = new Mock>();
@@ -146,8 +146,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
requestContext.VerifyAll();
}
- [Fact]
- public async void VerifyMetadataList()
+ [Test]
+ public async Task VerifyMetadataList()
{
string query = @"CREATE TABLE testTable1 (c1 int)
GO
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj
index a3435d4c..b4d210f7 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj
@@ -20,8 +20,9 @@
-
-
+
+
+
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs
index 99dbbd99..91287dbf 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs
@@ -17,7 +17,7 @@ using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined;
using Microsoft.SqlTools.ServiceLayer.Test.Common.Extensions;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.ObjectExplorer.ObjectExplorerService;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
@@ -26,8 +26,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{
private ObjectExplorerService _service = TestServiceProvider.Instance.ObjectExplorerService;
- [Fact]
- public async void CreateSessionAndExpandOnTheServerShouldReturnServerAsTheRoot()
+ [Test]
+ public async Task CreateSessionAndExpandOnTheServerShouldReturnServerAsTheRoot()
{
var query = "";
string databaseName = null;
@@ -37,8 +37,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void CreateSessionWithTempdbAndExpandOnTheServerShouldReturnServerAsTheRoot()
+ [Test]
+ public async Task CreateSessionWithTempdbAndExpandOnTheServerShouldReturnServerAsTheRoot()
{
var query = "";
string databaseName = "tempdb";
@@ -48,8 +48,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void VerifyServerLogins()
+ [Test]
+ public async Task VerifyServerLogins()
{
var query = $@"If Exists (select loginname from master.dbo.syslogins
where name = 'OEServerLogin')
@@ -77,8 +77,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void VerifyServerTriggers()
+ [Test]
+ public async Task VerifyServerTriggers()
{
var query = @"IF EXISTS (SELECT * FROM sys.server_triggers WHERE name = 'OE_ddl_trig_database')
@@ -113,8 +113,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void CreateSessionAndExpandOnTheDatabaseShouldReturnDatabaseAsTheRoot()
+ [Test]
+ public async Task CreateSessionAndExpandOnTheDatabaseShouldReturnDatabaseAsTheRoot()
{
var query = "";
string databaseName = "#testDb#";
@@ -124,8 +124,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void RefreshNodeShouldGetTheDataFromDatabase()
+ [Test]
+ public async Task RefreshNodeShouldGetTheDataFromDatabase()
{
var query = "Create table t1 (c1 int)";
string databaseName = "#testDb#";
@@ -148,8 +148,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
/// Create a test database with prefix (OfflineDb). Create an oe session for master db and expand the new test db.
/// The expand should return an error that says database if offline
///
- [Fact]
- public async void ExpandOfflineDatabaseShouldReturnError()
+ [Test]
+ public async Task ExpandOfflineDatabaseShouldReturnError()
{
var query = "ALTER DATABASE {0} SET OFFLINE WITH ROLLBACK IMMEDIATE";
string databaseName = "master";
@@ -162,8 +162,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
});
}
- [Fact]
- public async void RefreshShouldCleanTheCache()
+ [Test]
+ public async Task RefreshShouldCleanTheCache()
{
string query = @"Create table t1 (c1 int)
GO
@@ -220,7 +220,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
var tableChildren = (await _service.ExpandNode(session, tablePath, true)).Nodes;
//Verify table is not returned
- Assert.Equal(tableChildren.Any(t => t.Label == tableName), !deleted);
+ Assert.AreEqual(tableChildren.Any(t => t.Label == tableName), !deleted);
//Verify tables cache has items
rootChildrenCache = session.Root.GetChildren();
@@ -228,8 +228,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.True(tablesCache.Any());
}
- [Fact]
- public async void VerifyAllSqlObjects()
+ [Test]
+ public async Task VerifyAllSqlObjects()
{
var queryFileName = "AllSqlObjects.sql";
string baselineFileName = "AllSqlObjects.txt";
@@ -237,9 +237,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
await TestServiceProvider.CalculateRunTime(() => VerifyObjectExplorerTest(databaseName, "AllSqlObjects", queryFileName, baselineFileName), true);
}
- //[Fact]
+ //[Test]
//This takes take long to run so not a good test for CI builds
- public async void VerifySystemObjects()
+ public async Task VerifySystemObjects()
{
string queryFileName = null;
string baselineFileName = null;
@@ -299,19 +299,19 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.NotNull(session);
Assert.NotNull(session.Root);
NodeInfo nodeInfo = session.Root.ToNodeInfo();
- Assert.Equal(nodeInfo.IsLeaf, false);
+ Assert.AreEqual(false, nodeInfo.IsLeaf);
NodeInfo databaseNode = null;
if (serverNode)
{
- Assert.Equal(nodeInfo.NodeType, NodeTypes.Server.ToString());
+ Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Server.ToString());
var children = session.Root.Expand(new CancellationToken());
//All server children should be folder nodes
foreach (var item in children)
{
- Assert.Equal(item.NodeType, "Folder");
+ Assert.AreEqual("Folder", item.NodeType);
}
var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases);
@@ -331,7 +331,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
}
else
{
- Assert.Equal(nodeInfo.NodeType, NodeTypes.Database.ToString());
+ Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Database.ToString());
databaseNode = session.Root.ToNodeInfo();
Assert.True(databaseNode.Label.Contains(databaseName));
var databasesChildren = (await _service.ExpandNode(session, databaseNode.NodePath)).Nodes;
@@ -347,15 +347,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.NotNull(session);
Assert.NotNull(session.Root);
NodeInfo nodeInfo = session.Root.ToNodeInfo();
- Assert.Equal(nodeInfo.IsLeaf, false);
- Assert.Equal(nodeInfo.NodeType, NodeTypes.Database.ToString());
+ Assert.AreEqual(false, nodeInfo.IsLeaf);
+ Assert.AreEqual(nodeInfo.NodeType, NodeTypes.Database.ToString());
Assert.True(nodeInfo.Label.Contains(databaseName));
var children = (await _service.ExpandNode(session, session.Root.GetNodePath())).Nodes;
//All server children should be folder nodes
foreach (var item in children)
{
- Assert.Equal(item.NodeType, "Folder");
+ Assert.AreEqual("Folder", item.NodeType);
}
var tablesRoot = children.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_Tables);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Profiler/ProfilerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Profiler/ProfilerServiceTests.cs
index 7437acba..f54c7686 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Profiler/ProfilerServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Profiler/ProfilerServiceTests.cs
@@ -18,7 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
{
@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
///
/// Verify that a start profiling request starts a profiling session
///
- //[Fact]
+ //[Test]
public async Task TestHandleStartAndStopProfilingRequests()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -76,7 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
///
/// Verify the profiler service XEvent session factory
///
- //[Fact]
+ //[Test]
public void TestCreateXEventSession()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/DataStorage/StorageDataReaderTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/DataStorage/StorageDataReaderTests.cs
index 95a7157b..f5b35462 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/DataStorage/StorageDataReaderTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/DataStorage/StorageDataReaderTests.cs
@@ -8,7 +8,7 @@ using System.Data.Common;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution.DataStorage
{
@@ -30,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution.DataSt
///
/// Validate GetBytesWithMaxCapacity
///
- [Fact]
+ [Test]
public void GetBytesWithMaxCapacityTest()
{
var storageReader = GetTestStorageDataReader(
@@ -47,7 +47,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution.DataSt
///
/// Validate GetCharsWithMaxCapacity
///
- [Fact]
+ [Test]
public void GetCharsWithMaxCapacityTest()
{
var storageReader = GetTestStorageDataReader(
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution.DataSt
///
/// Validate GetXmlWithMaxCapacity
///
- [Fact]
+ [Test]
public void GetXmlWithMaxCapacityTest()
{
var storageReader = GetTestStorageDataReader(
@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution.DataSt
///
/// Validate StringWriterWithMaxCapacity Write test
///
- [Fact]
+ [Test]
public void StringWriterWithMaxCapacityTest()
{
var writer = new StorageDataReader.StringWriterWithMaxCapacity(null, 4);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/ExecuteTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/ExecuteTests.cs
index 209d7844..69df4248 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/ExecuteTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/ExecuteTests.cs
@@ -6,19 +6,20 @@
using System;
using System.Collections.Concurrent;
using System.Data.Common;
+using System.Linq;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
{
public class ExecuteTests
{
- [Fact]
+ [Test]
public void RollbackTransactionFailsWithoutBeginTransaction()
{
const string refactorText = "ROLLBACK TRANSACTION";
@@ -37,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
Assert.True(query.Batches[0].HasError);
}
- [Fact]
+ [Test]
public void TransactionsSucceedAcrossQueries()
{
const string beginText = "BEGIN TRANSACTION";
@@ -56,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
Assert.False(rollbackQuery.Batches[0].HasError);
}
- [Fact]
+ [Test]
public void TempTablesPersistAcrossQueries()
{
const string createTempText = "CREATE TABLE #someTempTable (id int)";
@@ -75,7 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
Assert.False(insertTempQuery.Batches[0].HasError);
}
- [Fact]
+ [Test]
public void DatabaseChangesWhenCallingUseDatabase()
{
const string master = "master";
@@ -92,27 +93,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
// If I use master, the current database should be master
CreateAndExecuteQuery(string.Format(useQuery, master), connInfo, fileStreamFactory);
- Assert.Equal(master, connInfo.ConnectionDetails.DatabaseName);
+ Assert.AreEqual(master, connInfo.ConnectionDetails.DatabaseName);
// If I use tempdb, the current database should be tempdb
CreateAndExecuteQuery(string.Format(useQuery, tempdb), connInfo, fileStreamFactory);
- Assert.Equal(tempdb, connInfo.ConnectionDetails.DatabaseName);
+ Assert.AreEqual(tempdb, connInfo.ConnectionDetails.DatabaseName);
// If I switch back to master, the current database should be master
CreateAndExecuteQuery(string.Format(useQuery, master), connInfo, fileStreamFactory);
- Assert.Equal(master, connInfo.ConnectionDetails.DatabaseName);
- }
-
- [Fact]
- public void TestBatchExecutionTime() {
- var result = LiveConnectionHelper.InitLiveConnectionInfo();
- ConnectionInfo connInfo = result.ConnectionInfo;
- var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
- Query query = CreateAndExecuteQuery("select * from sys.databases", connInfo, fileStreamFactory);
- DateTime elapsedTime = Convert.ToDateTime(query.Batches[0].ExecutionElapsedTime);
- Query mutipleQuery = CreateAndExecuteQuery("select * from sys.databases\r\nGO 15", connInfo, fileStreamFactory);
- DateTime multipleElapsedTime = Convert.ToDateTime(mutipleQuery.Batches[0].ExecutionElapsedTime);
- Assert.True(multipleElapsedTime > elapsedTime);
+ Assert.AreEqual(master, connInfo.ConnectionDetails.DatabaseName);
}
public static Query CreateAndExecuteQuery(string queryText, ConnectionInfo connectionInfo, IFileStreamFactory fileStreamFactory, bool IsSqlCmd = false)
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/SqlCmdExecutionTest.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/SqlCmdExecutionTest.cs
index 50ac1da9..f69f29b4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/SqlCmdExecutionTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/QueryExecution/SqlCmdExecutionTest.cs
@@ -9,13 +9,13 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using System;
using System.IO;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.QueryExecution
{
public class SqlCmdExecutionTest
{
- [Fact]
+ [Test]
public void TestConnectSqlCmdCommand()
{
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
@@ -41,7 +41,7 @@ GO";
Assert.True(query.Batches[0].HasError, "Query should have error");
}
- [Fact]
+ [Test]
public void TestOnErrorSqlCmdCommand()
{
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
@@ -73,7 +73,7 @@ GO";
Assert.False(query.Batches[1].HasExecuted, "last batch should NOT be executed");
}
- [Fact]
+ [Test]
public void TestIncludeSqlCmdCommand()
{
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceOptionsTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceOptionsTests.cs
index 4be874fc..9c289841 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceOptionsTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceOptionsTests.cs
@@ -12,7 +12,7 @@ using Moq;
using System;
using System.IO;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
@@ -265,8 +265,8 @@ END
{
// validate script generation failed because there were no differences
Assert.False(generateScriptOperation1.ScriptGenerationResult.Success);
- Assert.Equal("Performing script generation is not possible for this comparison result.", generateScriptOperation1.ScriptGenerationResult.Message);
- Assert.Equal("Performing script generation is not possible for this comparison result.", ex.Message);
+ Assert.AreEqual("Performing script generation is not possible for this comparison result.", generateScriptOperation1.ScriptGenerationResult.Message);
+ Assert.AreEqual("Performing script generation is not possible for this comparison result.", ex.Message);
}
var schemaCompareParams2 = new SchemaCompareParams
@@ -309,8 +309,8 @@ END
///
/// Verify the schema compare request comparing two dacpacs with and without ignore column option
///
- [Fact]
- public async void SchemaCompareDacpacToDacpacOptions()
+ [Test]
+ public async Task SchemaCompareDacpacToDacpacOptions()
{
await SendAndValidateSchemaCompareRequestDacpacToDacpacWithOptions(Source1, Target1, GetIgnoreColumnOptions(), new DeploymentOptions());
}
@@ -318,8 +318,8 @@ END
///
/// Verify the schema compare request comparing two dacpacs with and excluding table valued functions
///
- [Fact]
- public async void SchemaCompareDacpacToDacpacObjectTypes()
+ [Test]
+ public async Task SchemaCompareDacpacToDacpacObjectTypes()
{
await SendAndValidateSchemaCompareRequestDacpacToDacpacWithOptions(Source2, Target2, GetExcludeTableValuedFunctionOptions(), new DeploymentOptions());
}
@@ -327,8 +327,8 @@ END
///
/// Verify the schema compare request comparing two databases with and without ignore column option
///
- [Fact]
- public async void SchemaCompareDatabaseToDatabaseOptions()
+ [Test]
+ public async Task SchemaCompareDatabaseToDatabaseOptions()
{
await SendAndValidateSchemaCompareRequestDatabaseToDatabaseWithOptions(Source1, Target1, GetIgnoreColumnOptions(), new DeploymentOptions());
}
@@ -336,8 +336,8 @@ END
///
/// Verify the schema compare request comparing two databases with and excluding table valued functions
///
- [Fact]
- public async void SchemaCompareDatabaseToDatabaseObjectTypes()
+ [Test]
+ public async Task SchemaCompareDatabaseToDatabaseObjectTypes()
{
await SendAndValidateSchemaCompareRequestDatabaseToDatabaseWithOptions(Source2, Target2, GetExcludeTableValuedFunctionOptions(), new DeploymentOptions());
}
@@ -345,8 +345,8 @@ END
///
/// Verify the schema compare script generation comparing dacpac and db with and without ignore column option
///
- [Fact]
- public async void SchemaCompareGenerateScriptDacpacToDatabaseOptions()
+ [Test]
+ public async Task SchemaCompareGenerateScriptDacpacToDatabaseOptions()
{
await SendAndValidateSchemaCompareGenerateScriptRequestDacpacToDatabaseWithOptions(Source1, Target1, GetIgnoreColumnOptions(), new DeploymentOptions());
}
@@ -354,8 +354,8 @@ END
///
/// Verify the schema compare script generation comparing dacpac and db with and excluding table valued function
///
- [Fact]
- public async void SchemaCompareGenerateScriptDacpacToDatabaseObjectTypes()
+ [Test]
+ public async Task SchemaCompareGenerateScriptDacpacToDatabaseObjectTypes()
{
await SendAndValidateSchemaCompareGenerateScriptRequestDacpacToDatabaseWithOptions(Source2, Target2, GetExcludeTableValuedFunctionOptions(), new DeploymentOptions());
}
@@ -363,7 +363,7 @@ END
///
/// Verify the schema compare default creation test
///
- [Fact]
+ [Test]
public void ValidateSchemaCompareOptionsDefaultAgainstDacFx()
{
DeploymentOptions deployOptions = new DeploymentOptions();
@@ -384,8 +384,8 @@ END
///
/// Verify the schema compare default creation test
///
- [Fact]
- public async void ValidateSchemaCompareGetDefaultOptionsCallFromService()
+ [Test]
+ public async Task ValidateSchemaCompareGetDefaultOptionsCallFromService()
{
DeploymentOptions deployOptions = new DeploymentOptions();
var schemaCompareRequestContext = new Mock>();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceTests.cs
index 6a0a71a8..f395cee4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SchemaCompare/SchemaCompareServiceTests.cs
@@ -16,8 +16,9 @@ using Microsoft.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using Xunit;
-
+using NUnit.Framework;
+using System.Diagnostics;
+
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
public class SchemaCompareServiceTests
@@ -78,8 +79,8 @@ WITH VALUES
///
/// Verify the schema compare request comparing two dacpacs
///
- [Fact]
- public async void SchemaCompareDacpacToDacpac()
+ [Test]
+ public async Task SchemaCompareDacpacToDacpac()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
@@ -122,8 +123,8 @@ WITH VALUES
///
/// Verify the schema compare request comparing a two databases
///
- [Fact]
- public async void SchemaCompareDatabaseToDatabase()
+ [Test]
+ public async Task SchemaCompareDatabaseToDatabase()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -161,8 +162,8 @@ WITH VALUES
///
/// Verify the schema compare request comparing a database to a dacpac
///
- [Fact]
- public async void SchemaCompareDatabaseToDacpac()
+ [Test]
+ public async Task SchemaCompareDatabaseToDacpac()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -202,8 +203,8 @@ WITH VALUES
///
/// Verify the schema compare generate script request comparing a database to a database
///
- [Fact]
- public async void SchemaCompareGenerateScriptDatabaseToDatabase()
+ [Test]
+ public async Task SchemaCompareGenerateScriptDatabaseToDatabase()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
var schemaCompareRequestContext = new Mock>();
@@ -249,8 +250,8 @@ WITH VALUES
///
/// Verify the schema compare generate script request comparing a dacpac to a database
///
- [Fact]
- public async void SchemaCompareGenerateScriptDacpacToDatabase()
+ [Test]
+ public async Task SchemaCompareGenerateScriptDacpacToDatabase()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -300,8 +301,8 @@ WITH VALUES
///
/// Verify the schema compare publish changes request comparing a dacpac to a database
///
- [Fact]
- public async void SchemaComparePublishChangesDacpacToDatabase()
+ [Test]
+ public async Task SchemaComparePublishChangesDacpacToDatabase()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -349,14 +350,14 @@ WITH VALUES
SchemaComparePublishChangesOperation publishChangesOperation = new SchemaComparePublishChangesOperation(publishChangesParams, schemaCompareOperation.ComparisonResult);
publishChangesOperation.Execute(TaskExecutionMode.Execute);
Assert.True(publishChangesOperation.PublishResult.Success);
- Assert.Empty(publishChangesOperation.PublishResult.Errors);
+ Assert.That(publishChangesOperation.PublishResult.Errors, Is.Empty);
// Verify that there are no differences after the publish by running the comparison again
schemaCompareOperation.Execute(TaskExecutionMode.Execute);
Assert.True(schemaCompareOperation.ComparisonResult.IsValid);
Assert.True(schemaCompareOperation.ComparisonResult.IsEqual);
- Assert.Empty(schemaCompareOperation.ComparisonResult.Differences);
+ Assert.That(schemaCompareOperation.ComparisonResult.Differences, Is.Empty);
// cleanup
SchemaCompareTestUtils.VerifyAndCleanup(sourceDacpacFilePath);
@@ -371,8 +372,8 @@ WITH VALUES
///
/// Verify the schema compare publish changes request comparing a database to a database
///
- [Fact]
- public async void SchemaComparePublishChangesDatabaseToDatabase()
+ [Test]
+ public async Task SchemaComparePublishChangesDatabaseToDatabase()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -416,14 +417,14 @@ WITH VALUES
SchemaComparePublishChangesOperation publishChangesOperation = new SchemaComparePublishChangesOperation(publishChangesParams, schemaCompareOperation.ComparisonResult);
publishChangesOperation.Execute(TaskExecutionMode.Execute);
Assert.True(publishChangesOperation.PublishResult.Success);
- Assert.Empty(publishChangesOperation.PublishResult.Errors);
+ Assert.That(publishChangesOperation.PublishResult.Errors, Is.Empty);
// Verify that there are no differences after the publish by running the comparison again
schemaCompareOperation.Execute(TaskExecutionMode.Execute);
Assert.True(schemaCompareOperation.ComparisonResult.IsValid);
Assert.True(schemaCompareOperation.ComparisonResult.IsEqual);
- Assert.Empty(schemaCompareOperation.ComparisonResult.Differences);
+ Assert.That(schemaCompareOperation.ComparisonResult.Differences, Is.Empty);
}
finally
{
@@ -435,8 +436,8 @@ WITH VALUES
///
/// Verify the schema compare Scmp File Save for database endpoints
///
- [Fact]
- public async void SchemaCompareSaveScmpFileForDatabases()
+ [Test]
+ public async Task SchemaCompareSaveScmpFileForDatabases()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
@@ -465,8 +466,8 @@ WITH VALUES
///
/// Verify the schema compare Scmp File Save for dacpac endpoints
///
- [Fact]
- public async void SchemaCompareSaveScmpFileForDacpacs()
+ [Test]
+ public async Task SchemaCompareSaveScmpFileForDacpacs()
{
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
SqlTestDb targetDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, TargetScript, "SchemaCompareTarget");
@@ -497,8 +498,8 @@ WITH VALUES
///
/// Verify the schema compare Scmp File Save for dacpac and db endpoints combination
///
- [Fact]
- public async void SchemaCompareSaveScmpFileForDacpacToDB()
+ [Test]
+ public async Task SchemaCompareSaveScmpFileForDacpacToDB()
{
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
SqlTestDb targetDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, TargetScript, "SchemaCompareTarget");
@@ -528,8 +529,8 @@ WITH VALUES
///
/// Verify opening an scmp comparing two databases
///
- [Fact]
- public async void SchemaCompareOpenScmpDatabaseToDatabaseRequest()
+ [Test]
+ public async Task SchemaCompareOpenScmpDatabaseToDatabaseRequest()
{
await CreateAndOpenScmp(SchemaCompareEndpointType.Database, SchemaCompareEndpointType.Database);
}
@@ -537,8 +538,8 @@ WITH VALUES
///
/// Verify opening an scmp comparing a dacpac and database
///
- [Fact]
- public async void SchemaCompareOpenScmpDacpacToDatabaseRequest()
+ [Test]
+ public async Task SchemaCompareOpenScmpDacpacToDatabaseRequest()
{
await CreateAndOpenScmp(SchemaCompareEndpointType.Dacpac, SchemaCompareEndpointType.Database);
}
@@ -546,8 +547,8 @@ WITH VALUES
///
/// Verify opening an scmp comparing two dacpacs
///
- [Fact]
- public async void SchemaCompareOpenScmpDacpacToDacpacRequest()
+ [Test]
+ public async Task SchemaCompareOpenScmpDacpacToDacpacRequest()
{
await CreateAndOpenScmp(SchemaCompareEndpointType.Dacpac, SchemaCompareEndpointType.Dacpac);
}
@@ -555,7 +556,7 @@ WITH VALUES
///
/// Verify the schema compare Service Calls ends to end
///
- [Fact]
+ [Test]
public async Task VerifySchemaCompareServiceCalls()
{
string operationId = Guid.NewGuid().ToString();
@@ -695,8 +696,8 @@ WITH VALUES
///
/// Verify the schema compare cancel
///
- [Fact]
- public async void SchemaCompareCancelCompareOperation()
+ [Test]
+ public async Task SchemaCompareCancelCompareOperation()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
@@ -746,8 +747,8 @@ WITH VALUES
/// test to verify recent dacfx bugs
/// does not need all combinations of db and dacpacs
///
- //[Fact] disabling the failing test is failing now.
- public async void SchemaCompareCEKAndFilegoupTest()
+ //[Test] disabling the failing test is failing now.
+ public async Task SchemaCompareCEKAndFilegoupTest()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, CreateKey, "SchemaCompareSource");
@@ -819,8 +820,8 @@ WITH VALUES
///
/// Verify the schema compare request with failing exclude request because of dependencies and that include will include dependencies
///
- [Fact]
- public async void SchemaCompareIncludeExcludeWithDependencies()
+ [Test]
+ public async Task SchemaCompareIncludeExcludeWithDependencies()
{
var result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceIncludeExcludeScript, "SchemaCompareSource");
@@ -1031,7 +1032,7 @@ WITH VALUES
// create a comparison and exclude the first difference
SchemaComparison compare = new SchemaComparison(sourceEndpoint, targetEndpoint);
SchemaComparisonResult result = compare.Compare();
- Assert.NotEmpty(result.Differences);
+ Assert.That(result.Differences, Is.Not.Empty);
SchemaDifference difference = result.Differences.First();
if (difference.SourceObject != null)
{
@@ -1059,10 +1060,10 @@ WITH VALUES
Assert.NotNull(schemaCompareOpenScmpOperation.Result);
Assert.True(schemaCompareOpenScmpOperation.Result.Success);
- Assert.NotEmpty(schemaCompareOpenScmpOperation.Result.ExcludedSourceElements);
- Assert.Equal(1, schemaCompareOpenScmpOperation.Result.ExcludedSourceElements.Count());
- Assert.Empty(schemaCompareOpenScmpOperation.Result.ExcludedTargetElements);
- Assert.Equal(targetDb.DatabaseName, schemaCompareOpenScmpOperation.Result.OriginalTargetName);
+ Assert.That(schemaCompareOpenScmpOperation.Result.ExcludedSourceElements, Is.Not.Empty);
+ Assert.AreEqual(1, schemaCompareOpenScmpOperation.Result.ExcludedSourceElements.Count());
+ Assert.That(schemaCompareOpenScmpOperation.Result.ExcludedTargetElements, Is.Empty);
+ Assert.AreEqual(targetDb.DatabaseName, schemaCompareOpenScmpOperation.Result.OriginalTargetName);
ValidateResultEndpointInfo(sourceEndpoint, schemaCompareOpenScmpOperation.Result.SourceEndpointInfo, sourceDb.ConnectionString);
ValidateResultEndpointInfo(targetEndpoint, schemaCompareOpenScmpOperation.Result.TargetEndpointInfo, targetDb.ConnectionString);
@@ -1093,13 +1094,13 @@ WITH VALUES
if (resultEndpoint.EndpointType == SchemaCompareEndpointType.Dacpac)
{
SchemaCompareDacpacEndpoint dacpacEndpoint = originalEndpoint as SchemaCompareDacpacEndpoint;
- Assert.Equal(dacpacEndpoint.FilePath, resultEndpoint.PackageFilePath);
+ Assert.AreEqual(dacpacEndpoint.FilePath, resultEndpoint.PackageFilePath);
}
else
{
SchemaCompareDatabaseEndpoint databaseEndpoint = originalEndpoint as SchemaCompareDatabaseEndpoint;
- Assert.Equal(databaseEndpoint.DatabaseName, resultEndpoint.DatabaseName);
- Assert.Contains(resultEndpoint.ConnectionDetails.ConnectionString, connectionString); // connectionString has password but resultEndpoint doesn't
+ Assert.AreEqual(databaseEndpoint.DatabaseName, resultEndpoint.DatabaseName);
+ Assert.That(connectionString, Does.Contain(resultEndpoint.ConnectionDetails.ConnectionString), "connectionString has password but resultEndpoint doesn't");
}
}
@@ -1117,20 +1118,20 @@ WITH VALUES
private void ValidateDiffEntryObjects(string[] diffObjectName, string diffObjectTypeType, TSqlObject dacfxObject)
{
- Assert.Equal(dacfxObject.Name.Parts.Count, diffObjectName.Length);
+ Assert.AreEqual(dacfxObject.Name.Parts.Count, diffObjectName.Length);
for (int i = 0; i < diffObjectName.Length; i++)
{
- Assert.Equal(dacfxObject.Name.Parts[i], diffObjectName[i]);
+ Assert.AreEqual(dacfxObject.Name.Parts[i], diffObjectName[i]);
}
var dacFxExcludedObject = new SchemaComparisonExcludedObjectId(dacfxObject.ObjectType, dacfxObject.Name);
var excludedObject = new SchemaComparisonExcludedObjectId(diffObjectTypeType, new ObjectIdentifier(diffObjectName));
- Assert.Equal(dacFxExcludedObject.Identifier.ToString(), excludedObject.Identifier.ToString());
- Assert.Equal(dacFxExcludedObject.TypeName, excludedObject.TypeName);
+ Assert.AreEqual(dacFxExcludedObject.Identifier.ToString(), excludedObject.Identifier.ToString());
+ Assert.AreEqual(dacFxExcludedObject.TypeName, excludedObject.TypeName);
string dacFxType = dacFxExcludedObject.TypeName;
- Assert.Equal(dacFxType, diffObjectTypeType);
+ Assert.AreEqual(dacFxType, diffObjectTypeType);
}
private void CreateAndValidateScmpFile(SchemaCompareEndpointInfo sourceInfo, SchemaCompareEndpointInfo targetInfo, bool isSourceDb, bool isTargetDb)
@@ -1236,7 +1237,8 @@ WITH VALUES
private void ValidateTask(string expectedTaskName)
{
- int retry = 5;
+ // upped the retry count to 20 so tests pass against remote servers more readily
+ int retry = 20;
Assert.True(TaskService.Instance.TaskManager.Tasks.Count == 1, $"Expected 1 task but found {TaskService.Instance.TaskManager.Tasks.Count} tasks");
while (TaskService.Instance.TaskManager.Tasks.Any() && retry > 0)
{
@@ -1259,6 +1261,7 @@ WITH VALUES
retry--;
}
Assert.False(TaskService.Instance.TaskManager.Tasks.Any(), $"No tasks were expected to exist but had {TaskService.Instance.TaskManager.Tasks.Count} [{string.Join(",", TaskService.Instance.TaskManager.Tasks.Select(t => t.TaskId))}]");
+ Console.WriteLine($"ValidateTask{expectedTaskName} completed at retry = {retry}");
TaskService.Instance.TaskManager.Reset();
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Scripting/ScriptingServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Scripting/ScriptingServiceTests.cs
index ace58057..7a781aeb 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Scripting/ScriptingServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Scripting/ScriptingServiceTests.cs
@@ -15,7 +15,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
@@ -76,8 +76,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
///
/// Verify the script object request
///
- [Fact]
- public async void ScriptingScript()
+ [Test]
+ public async Task ScriptingScript()
{
foreach (string obj in objects)
{
@@ -86,8 +86,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
}
}
- [Fact]
- public async void VerifyScriptAsCreateTable()
+ [Test]
+ public async Task VerifyScriptAsCreateTable()
{
string query = @"CREATE TABLE testTable1 (c1 int)
GO
@@ -110,8 +110,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAsForMultipleObjects(query, new List { scriptingObject }, scriptCreateDrop, expectedScripts);
}
- [Fact]
- public async void VerifyScriptAsExecuteTableFailes()
+ [Test]
+ public async Task VerifyScriptAsExecuteTableFailes()
{
string query = "CREATE TABLE testTable1 (c1 int)";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Execute;
@@ -125,8 +125,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsAlter()
+ [Test]
+ public async Task VerifyScriptAsAlter()
{
string query = @"CREATE PROCEDURE testSp1 @StartProductID [int] AS BEGIN Select * from sys.all_columns END
GO
@@ -168,8 +168,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
}
// TODO: Fix flaky test. See https://github.com/Microsoft/sqltoolsservice/issues/631
- // [Fact]
- public async void VerifyScriptAsExecuteStoredProcedure()
+ // [Test]
+ public async Task VerifyScriptAsExecuteStoredProcedure()
{
string query = @"CREATE PROCEDURE testSp1
@BusinessEntityID [int],
@@ -192,8 +192,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsSelectTable()
+ [Test]
+ public async Task VerifyScriptAsSelectTable()
{
string query = "CREATE TABLE testTable1 (c1 int)";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Select;
@@ -208,8 +208,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsCreateView()
+ [Test]
+ public async Task VerifyScriptAsCreateView()
{
string query = "CREATE VIEW testView1 AS SELECT * from sys.all_columns";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Create;
@@ -224,8 +224,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsCreateStoredProcedure()
+ [Test]
+ public async Task VerifyScriptAsCreateStoredProcedure()
{
string query = "CREATE PROCEDURE testSp1 AS BEGIN Select * from sys.all_columns END";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Create;
@@ -240,8 +240,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsDropTable()
+ [Test]
+ public async Task VerifyScriptAsDropTable()
{
string query = "CREATE TABLE testTable1 (c1 int)";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Delete;
@@ -256,8 +256,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsDropView()
+ [Test]
+ public async Task VerifyScriptAsDropView()
{
string query = "CREATE VIEW testView1 AS SELECT * from sys.all_columns";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Delete;
@@ -272,8 +272,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Scripting
await VerifyScriptAs(query, scriptingObject, scriptCreateDrop, expectedScript);
}
- [Fact]
- public async void VerifyScriptAsDropStoredProcedure()
+ [Test]
+ public async Task VerifyScriptAsDropStoredProcedure()
{
string query = "CREATE PROCEDURE testSp1 AS BEGIN Select * from sys.all_columns END";
ScriptingOperationType scriptCreateDrop = ScriptingOperationType.Delete;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Security/CredentialTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Security/CredentialTests.cs
index cba15f65..1999c671 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Security/CredentialTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Security/CredentialTests.cs
@@ -14,7 +14,7 @@ using Microsoft.SqlTools.ServiceLayer.Security.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
///
/// TestHandleCreateCredentialRequest
///
- [Fact]
+ [Test]
public async Task TestHandleCreateCredentialRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -49,7 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
///
/// TestHandleUpdateCredentialRequest
///
- [Fact]
+ [Test]
public async Task TestHandleUpdateCredentialRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -72,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
///
/// TestHandleDeleteCredentialRequest
///
- [Fact]
+ [Test]
public async Task TestHandleDeleteCredentialRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ServerConfigurations/ServerConfigurationsServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ServerConfigurations/ServerConfigurationsServiceTests.cs
index f532c768..482b775d 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ServerConfigurations/ServerConfigurationsServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ServerConfigurations/ServerConfigurationsServiceTests.cs
@@ -13,22 +13,22 @@ using Moq;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.MachineLearningServices
{
public class ServerConfigurationsServiceTests
{
- [Fact]
- public async void VerifyListingConfigs()
+ [Test]
+ public async Task VerifyListingConfigs()
{
List configs = await GetAllConfigs();
Assert.NotNull(configs);
Assert.True(configs.Count > 0);
}
- [Fact]
- public async void VerifyUpdatingConfigs()
+ [Test]
+ public async Task VerifyUpdatingConfigs()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
@@ -59,14 +59,14 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.MachineLearningServic
await ServerConfigService.Instance.HandleServerConfigViewRequest(requestParams, requestContext.Object);
Assert.NotNull(result);
- Assert.Equal(result.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
+ Assert.AreEqual(result.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
await ServerConfigService.Instance.HandleServerConfigUpdateRequest(updateRequestParams, updateRequestContext.Object);
Assert.NotNull(updateResult);
- Assert.Equal(updateResult.ConfigProperty.ConfigValue, newValue);
+ Assert.AreEqual(updateResult.ConfigProperty.ConfigValue, newValue);
updateRequestParams.ConfigValue = sampleConfig.ConfigValue;
await ServerConfigService.Instance.HandleServerConfigUpdateRequest(updateRequestParams, updateRequestContext.Object);
Assert.NotNull(updateResult);
- Assert.Equal(updateResult.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
+ Assert.AreEqual(updateResult.ConfigProperty.ConfigValue, sampleConfig.ConfigValue);
ServerConfigService.Instance.ConnectionServiceInstance.Disconnect(new DisconnectParams
{
OwnerUri = queryTempFile.FilePath,
@@ -97,8 +97,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.MachineLearningServic
}
- [Fact]
- public async void VerifyConfigViewRequestSendErrorGivenInvalidConnection()
+ [Test]
+ public async Task VerifyConfigViewRequestSendErrorGivenInvalidConnection()
{
ServerConfigViewResponseParams result = null;
var requestContext = RequestContextMocks.Create(r => result = r).AddErrorHandling(null);
@@ -113,8 +113,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.MachineLearningServic
requestContext.Verify(x => x.SendError(It.IsAny()));
}
- [Fact]
- public async void VerifyConfigUpdateRequestSendErrorGivenInvalidConnection()
+ [Test]
+ public async Task VerifyConfigUpdateRequestSendErrorGivenInvalidConnection()
{
ServerConfigUpdateResponseParams result = null;
var requestContext = RequestContextMocks.Create(r => result = r).AddErrorHandling(null);
@@ -130,8 +130,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.MachineLearningServic
requestContext.Verify(x => x.SendError(It.IsAny()));
}
- [Fact]
- public async void VerifyConfigListRequestSendErrorGivenInvalidConnection()
+ [Test]
+ public async Task VerifyConfigListRequestSendErrorGivenInvalidConnection()
{
ServerConfigListResponseParams result = null;
var requestContext = RequestContextMocks.Create(r => result = r).AddErrorHandling(null);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SqlAssessment/SqlAssessmentServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SqlAssessment/SqlAssessmentServiceTests.cs
index a98ee6b4..e99ecc19 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SqlAssessment/SqlAssessmentServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/SqlAssessment/SqlAssessmentServiceTests.cs
@@ -20,8 +20,6 @@ using Microsoft.SqlTools.ServiceLayer.SqlAssessment;
using Microsoft.SqlTools.ServiceLayer.SqlAssessment.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using NUnit.Framework;
-using Xunit;
-using Assert = Xunit.Assert;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
{
@@ -31,8 +29,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
private static readonly string[] AllowedSeverityLevels = { "Information", "Warning", "Critical" };
- [Fact]
- public async void InvokeSqlAssessmentServerTest()
+ [Test]
+ public async Task InvokeSqlAssessmentServerTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
@@ -46,23 +44,19 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
SqlObjectType.Server,
liveConnection);
- Assert.All(
- response.Items,
- i =>
- {
- Assert.NotNull(i.Message);
- Assert.NotEmpty(i.Message);
- Assert.Equal(serverInfo.ServerName, i.TargetName);
-
- if (i.Kind == 0)
- {
- AssertInfoPresent(i);
- }
- });
+ Assert.Multiple(() =>
+ {
+ Assert.That(response.Items.Select(i => i.Message), Has.All.Not.Null.Or.Empty);
+ Assert.That(response.Items.Select(i => i.TargetName), Has.All.EqualTo(serverInfo.ServerName));
+ foreach (var i in response.Items.Where(i => i.Kind == 0))
+ {
+ AssertInfoPresent(i);
+ }
+ });
}
- [Fact]
- public async void GetAssessmentItemsServerTest()
+ [Test]
+ public async Task GetAssessmentItemsServerTest()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
@@ -76,17 +70,18 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
SqlObjectType.Server,
liveConnection);
- Assert.All(
- response.Items,
- i =>
+ Assert.Multiple(() =>
+ {
+ Assert.That(response.Items.Select(i => i.TargetName), Has.All.EqualTo(serverInfo.ServerName));
+ foreach (var i in response.Items)
{
AssertInfoPresent(i);
- Assert.Equal(serverInfo.ServerName, i.TargetName);
- });
+ }
+ });
}
- [Fact]
- public async void GetAssessmentItemsDatabaseTest()
+ [Test]
+ public async Task GetAssessmentItemsDatabaseTest()
{
const string DatabaseName = "tempdb";
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(DatabaseName);
@@ -95,17 +90,18 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
SqlObjectType.Database,
liveConnection);
- Assert.All(
- response.Items,
- i =>
+ Assert.Multiple(() =>
+ {
+ Assert.That(response.Items.Select(i => i.TargetName), Has.All.EndsWith(":" + DatabaseName));
+ foreach (var i in response.Items)
{
- StringAssert.EndsWith(":" + DatabaseName, i.TargetName);
AssertInfoPresent(i);
- });
+ }
+ });
}
- [Fact]
- public async void InvokeSqlAssessmentIDatabaseTest()
+ [Test]
+ public async Task InvokeSqlAssessmentIDatabaseTest()
{
const string DatabaseName = "tempdb";
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(DatabaseName);
@@ -114,19 +110,15 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
SqlObjectType.Database,
liveConnection);
- Assert.All(
- response.Items,
- i =>
+ Assert.Multiple(() =>
+ {
+ Assert.That(response.Items.Select(i => i.Message), Has.All.Not.Null.Or.Empty);
+ Assert.That(response.Items.Select(i => i.TargetName), Has.All.EndsWith(":" + DatabaseName));
+ foreach (var i in response.Items.Where(i => i.Kind == 0))
{
- StringAssert.EndsWith(":" + DatabaseName, i.TargetName);
- Assert.NotNull(i.Message);
- Assert.NotEmpty(i.Message);
-
- if (i.Kind == 0)
- {
- AssertInfoPresent(i);
- }
- });
+ AssertInfoPresent(i);
+ }
+ });
}
private static async Task> CallAssessment(
@@ -176,13 +168,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
Assert.NotNull(response);
if (response.Success)
{
- Assert.All(
- response.Items,
- i =>
- {
- Assert.Equal(sqlObjectType, i.TargetType);
- Assert.Contains(i.Level, AllowedSeverityLevels);
- });
+ Assert.That(response.Items.Select(i => i.TargetType), Has.All.EqualTo(sqlObjectType));
+ Assert.That(response.Items.Select(i => i.Level), Has.All.AnyOf(AllowedSeverityLevels));
}
return response;
@@ -225,17 +212,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
private void AssertInfoPresent(AssessmentItemInfo item)
{
- Assert.NotNull(item.CheckId);
- Assert.NotEmpty(item.CheckId);
- Assert.NotNull(item.DisplayName);
- Assert.NotEmpty(item.DisplayName);
- Assert.NotNull(item.Description);
- Assert.NotEmpty(item.Description);
- Assert.NotNull(item.Tags);
- Assert.All(item.Tags, t =>
+ Assert.Multiple(() =>
{
- Assert.NotNull(t);
- Assert.NotEmpty(t);
+ Assert.That(item.CheckId, Is.Not.Null.Or.Empty);
+ Assert.That(item.DisplayName, Is.Not.Null.Or.Empty);
+ Assert.That(item.Description, Is.Not.Null.Or.Empty);
+ Assert.NotNull(item.Tags);
+ Assert.That(item.Tags, Has.All.Not.Null.Or.Empty);
});
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/TaskServices/TaskServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/TaskServices/TaskServiceTests.cs
index 13580dec..61b1ba5d 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/TaskServices/TaskServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/TaskServices/TaskServiceTests.cs
@@ -20,7 +20,7 @@ using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
-using Xunit;
+using NUnit.Framework;
using static Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility.LiveConnectionHelper;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TaskServices
@@ -37,25 +37,25 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TaskServices
service.InitializeService(serviceHostMock.Object);
}
- [Fact]
+ [Test]
public async Task VerifyTaskExecuteTheQueryGivenExecutionModeExecute()
{
await VerifyTaskWithExecutionMode(TaskExecutionMode.Execute);
}
- [Fact]
+ [Test]
public async Task VerifyTaskGenerateScriptOnlyGivenExecutionModeScript()
{
await VerifyTaskWithExecutionMode(TaskExecutionMode.Script);
}
- [Fact]
+ [Test]
public async Task VerifyTaskNotExecuteAndGenerateScriptGivenExecutionModeExecuteAndScript()
{
await VerifyTaskWithExecutionMode(TaskExecutionMode.ExecuteAndScript);
}
- [Fact]
+ [Test]
public async Task VerifyTaskSendsFailureNotificationGivenInvalidQuery()
{
await VerifyTaskWithExecutionMode(TaskExecutionMode.ExecuteAndScript, true);
@@ -103,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.TaskServices
bool expected = executionMode == TaskExecutionMode.Execute || executionMode == TaskExecutionMode.ExecuteAndScript;
Server serverToverfiy = CreateServerObject(connectionResult.ConnectionInfo);
bool actual = serverToverfiy.Databases[testDb.DatabaseName].Tables.Contains(taskOperation.TableName, "test");
- Assert.Equal(expected, actual);
+ Assert.AreEqual(expected, actual);
}
else
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs
index 06b0ec18..bf957687 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Utility/LiveConnectionHelper.cs
@@ -10,7 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs
index 219a464d..9ada67f6 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Baselined/BaselinedTest.cs
@@ -7,7 +7,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Text;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common.Baselined
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj
index c8399d1f..0555a696 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/Microsoft.SqlTools.ServiceLayer.Test.Common.csproj
@@ -10,8 +10,9 @@
-
-
+
+
+
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs
index d9487f0f..8fb4050c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/RequestContextMocking/EventFlowValidator.cs
@@ -11,7 +11,7 @@ using Microsoft.SqlTools.Hosting.Contracts;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
{
@@ -99,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking
// Add an error validator that just ensures a non-empty error message and null data obj
return AddSimpleErrorValidation((msg, code) =>
{
- Assert.NotEmpty(msg);
+ Assert.That(msg, Is.Not.Null.Or.Empty, $"AddStandardErrorValidation msg for {code}");
});
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs
index c43c993b..9553d3ba 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/SqlTestDb.cs
@@ -7,7 +7,7 @@ using System;
using System.Globalization;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
-using Xunit;
+using NUnit.Framework;
using Microsoft.Data.SqlClient;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.Common;
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConnectionProfileService.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConnectionProfileService.cs
index f1d7fa42..08b89a06 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConnectionProfileService.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestConnectionProfileService.cs
@@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Globalization;
using Microsoft.SqlTools.Credentials.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestLogger.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestLogger.cs
index 904ba892..4baa8091 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestLogger.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestLogger.cs
@@ -9,7 +9,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
index fa8889d3..8a5428e5 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceDriverProvider.cs
@@ -18,7 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs
index e2a51dff..25fd2179 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestServiceProvider.cs
@@ -16,7 +16,7 @@ using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Workspace;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/ConnectionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/ConnectionTests.cs
index f7b5e369..68a7a8b4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/ConnectionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/ConnectionTests.cs
@@ -6,11 +6,12 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
+ [TestFixture]
///
/// Language Service end-to-end integration tests
///
@@ -19,16 +20,16 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Try to connect with invalid credentials
///
- [Fact]
+ [Test]
public async Task InvalidConnection()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{
- bool connected = await testService.Connect(queryTempFile.FilePath, InvalidConnectParams, 300000);
+ bool connected = await testService.Connect(queryTempFile.FilePath, InvalidConnectParams, 60000);
Assert.False(connected, "Invalid connection is failed to connect");
- await testService.Connect(queryTempFile.FilePath, InvalidConnectParams, 300000);
+ await testService.Connect(queryTempFile.FilePath, InvalidConnectParams, 60000);
Thread.Sleep(1000);
@@ -41,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validate list databases request
///
- [Fact]
+ [Test]
public async Task ListDatabasesTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/LanguageServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/LanguageServiceTests.cs
index f7803176..bb940dd7 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/LanguageServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/LanguageServiceTests.cs
@@ -10,10 +10,11 @@ using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
+ [TestFixture]
///
/// Language Service end-to-end integration tests
///
@@ -23,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validate hover tooltip scenarios
///
- [Fact]
+ [Test]
public async Task HoverTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -64,7 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validation autocompletion suggestions scenarios
///
- [Fact]
+ [Test]
public async Task CompletionTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -111,7 +112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validate diagnostic scenarios
///
- [Fact]
+ [Test]
public async Task DiagnosticsTests()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -214,7 +215,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
/// Peek Definition/ Go to definition
///
///
- [Fact]
+ [Test]
public async Task DefinitionTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -260,7 +261,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validate the configuration change event
///
- [Fact]
+ [Test]
public async Task ChangeConfigurationTest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -286,7 +287,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task NotificationIsSentAfterOnConnectionAutoCompleteUpdate()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -298,13 +299,13 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
// An event signalling that IntelliSense is ready should be sent shortly thereafter
var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000);
Assert.NotNull(readyParams);
- Assert.Equal(queryTempFile.FilePath, readyParams.OwnerUri);
+ Assert.AreEqual(queryTempFile.FilePath, readyParams.OwnerUri);
await testService.Disconnect(queryTempFile.FilePath);
}
}
- [Fact]
+ [Test]
public async Task FunctionSignatureCompletionReturnsEmptySignatureHelpObjectWhenThereAreNoMatches()
{
string sqlText = "EXEC sys.fn_not_a_real_function ";
@@ -321,7 +322,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
// Wait for intellisense to be ready
var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000);
Assert.NotNull(readyParams);
- Assert.Equal(ownerUri, readyParams.OwnerUri);
+ Assert.AreEqual(ownerUri, readyParams.OwnerUri);
// Send a function signature help Request
var position = new TextDocumentPosition()
@@ -346,7 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task FunctionSignatureCompletionReturnsCorrectFunction()
{
string sqlText = "EXEC sys.fn_isrolemember ";
@@ -362,7 +363,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
// Wait for intellisense to be ready
var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000);
Assert.NotNull(readyParams);
- Assert.Equal(ownerUri, readyParams.OwnerUri);
+ Assert.AreEqual(ownerUri, readyParams.OwnerUri);
// Send a function signature help Request
var position = new TextDocumentPosition()
@@ -381,18 +382,17 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
Assert.NotNull(signatureHelp);
Assert.True(signatureHelp.ActiveSignature.HasValue);
- Assert.NotEmpty(signatureHelp.Signatures);
+ Assert.That(signatureHelp.Signatures, Is.Not.Empty, "signatureHelp.Signatures after SendRequest");
var label = signatureHelp.Signatures[signatureHelp.ActiveSignature.Value].Label;
- Assert.NotNull(label);
- Assert.NotEmpty(label);
- Assert.True(label.Contains("fn_isrolemember"));
+ Assert.That(label, Is.Not.Null.Or.Empty, "label");
+ Assert.That(label, Contains.Substring("fn_isrolemember"), "label contents");
await testService.Disconnect(ownerUri);
}
}
- [Fact]
+ [Test]
public async Task FunctionSignatureCompletionReturnsCorrectParametersAtEachPosition()
{
string sqlText = "EXEC sys.fn_isrolemember 1, 'testing', 2";
@@ -409,7 +409,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
// Wait for intellisense to be ready
var readyParams = await testService.Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000);
Assert.NotNull(readyParams);
- Assert.Equal(ownerUri, readyParams.OwnerUri);
+ Assert.AreEqual(ownerUri, readyParams.OwnerUri);
// Verify all parameters when the cursor is inside of parameters and at separator boundaries (,)
await VerifyFunctionSignatureHelpParameter(testService, ownerUri, 25, "fn_isrolemember", 0, "@mode int");
@@ -449,25 +449,23 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
Assert.NotNull(signatureHelp);
Assert.NotNull(signatureHelp.ActiveSignature);
Assert.True(signatureHelp.ActiveSignature.HasValue);
- Assert.NotEmpty(signatureHelp.Signatures);
+ Assert.That(signatureHelp.Signatures, Is.Not.Empty, "Signatures");
var activeSignature = signatureHelp.Signatures[signatureHelp.ActiveSignature.Value];
Assert.NotNull(activeSignature);
var label = activeSignature.Label;
- Assert.NotNull(label);
- Assert.NotEmpty(label);
- Assert.True(label.Contains(expectedFunctionName));
+ Assert.That(label, Is.Not.Null.Or.Empty, "label");
+ Assert.That(label, Contains.Substring(expectedFunctionName), "label contents");
Assert.NotNull(signatureHelp.ActiveParameter);
Assert.True(signatureHelp.ActiveParameter.HasValue);
- Assert.Equal(expectedParameterIndex, signatureHelp.ActiveParameter.Value);
+ Assert.AreEqual(expectedParameterIndex, signatureHelp.ActiveParameter.Value);
var parameter = activeSignature.Parameters[signatureHelp.ActiveParameter.Value];
Assert.NotNull(parameter);
- Assert.NotNull(parameter.Label);
- Assert.NotEmpty(parameter.Label);
- Assert.Equal(expectedParameterName, parameter.Label);
+ Assert.That(parameter.Label, Is.Not.Null.Or.Empty, "parameter.Label");
+ Assert.AreEqual(expectedParameterName, parameter.Label);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests.csproj b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests.csproj
index 047c1f5c..26318c43 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests.csproj
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests.csproj
@@ -21,8 +21,9 @@
-
-
+
+
+
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Program.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Program.cs
index 3ea3a2f5..b79c55ab 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Program.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/Program.cs
@@ -9,9 +9,9 @@ using System.Reflection;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Driver;
using Microsoft.SqlTools.Utility;
-using Xunit;
+using NUnit.Framework;
-[assembly: CollectionBehavior(DisableTestParallelization = true)]
+[assembly: NonParallelizable]
// turn off entry point since this is xUnit project
#if false
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
index ead95330..e7d0b0f1 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/QueryExecutionTests.cs
@@ -5,14 +5,14 @@
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
public class QueryExecutionTests
{
/* Commenting out these tests until they are fixed (12/1/16)
- [Fact]
+ [Test]
public async Task TestQueryCancelReliability()
{
const string query = "SELECT * FROM sys.objects a CROSS JOIN sys.objects b CROSS JOIN sys.objects c";
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestQueryDoesNotBlockOtherRequests()
{
const string query = "SELECT * FROM sys.objects a CROSS JOIN sys.objects b CROSS JOIN sys.objects c";
@@ -67,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestParallelQueryExecution()
{
const int queryCount = 10;
@@ -102,7 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestSaveResultsDoesNotBlockOtherRequests()
{
const string query = "SELECT * FROM sys.objects";
@@ -146,7 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestQueryingSubsetDoesNotBlockOtherRequests()
{
const string query = "SELECT * FROM sys.objects";
@@ -183,7 +183,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestCancelQueryWhileOtherOperationsAreInProgress()
{
const string query = "SELECT * FROM sys.objects a CROSS JOIN sys.objects b";
@@ -220,7 +220,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task ExecuteBasicQueryTest()
{
const string query = "SELECT * FROM sys.all_columns c";
@@ -276,7 +276,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task TestQueryingAfterCompletionRequests()
{
const string query = "SELECT * FROM sys.objects";
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/SqlScriptPublishModelTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/SqlScriptPublishModelTests.cs
index 850d1017..7144ef14 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/SqlScriptPublishModelTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/SqlScriptPublishModelTests.cs
@@ -6,28 +6,31 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Scripting.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
+ [TestFixture]
///
/// Scripting service end-to-end integration tests that use the SqlScriptPublishModel type to generate scripts.
///
- public class SqlScriptPublishModelTests : IClassFixture
+ public class SqlScriptPublishModelTests
{
- public SqlScriptPublishModelTests(ScriptingFixture scriptingFixture)
+ [OneTimeSetUp]
+ public void SetupSqlScriptPublishModelTests()
{
- this.Fixture = scriptingFixture;
+ Fixture = new ScriptingFixture();
}
- public ScriptingFixture Fixture { get; private set; }
+ private static ScriptingFixture Fixture { get; set; }
- public SqlTestDb Northwind { get { return this.Fixture.Database; } }
+ private SqlTestDb Northwind { get { return Fixture.Database; } }
- [Fact]
+ [Test]
public async Task ListSchemaObjects()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -40,11 +43,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingListObjectsResult result = await testService.ListScriptingObjects(requestParams);
ScriptingListObjectsCompleteParams completeParameters = await testService.Driver.WaitForEvent(ScriptingListObjectsCompleteEvent.Type, TimeSpan.FromSeconds(30));
- Assert.Equal(ScriptingFixture.ObjectCountWithoutDatabase, completeParameters.ScriptingObjects.Count);
+ Assert.AreEqual(ScriptingFixture.ObjectCountWithoutDatabase, completeParameters.ScriptingObjects.Count);
}
}
- [Fact]
+ [Test]
public async Task ScriptDatabaseSchema()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -65,7 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task ScriptDatabaseSchemaAndData()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -86,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- [Fact]
+ [Test]
public async Task ScriptTable()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -115,11 +118,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(1));
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30));
Assert.True(parameters.Success);
- Assert.Equal(1, planEvent.Count);
+ Assert.AreEqual(1, planEvent.Count);
}
}
- [Fact]
+ [Test]
public async Task ScriptTableUsingIncludeFilter()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -147,11 +150,13 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(30));
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30));
Assert.True(parameters.Success);
- Assert.Equal(1, planEvent.Count);
+ // Work around SMO bug https://github.com/microsoft/sqlmanagementobjects/issues/19 which leads to non-unique URNs in the collection
+ Assert.That(planEvent.Count, Is.AtLeast(1), "ScripingPlanNotificationParams.Count");
+ Assert.That(planEvent.ScriptingObjects.All(obj => obj.Name == "Customers" && obj.Schema == "dbo" && obj.Type == "Table"), "ScriptingPlanNotificationParams.ScriptingObjects contents");
}
}
- [Fact]
+ [Test]
public async Task ScriptTableAndData()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -179,11 +184,13 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(30));
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30));
Assert.True(parameters.Success);
- Assert.Equal(1, planEvent.Count);
+ // Work around SMO bug https://github.com/microsoft/sqlmanagementobjects/issues/19 which leads to non-unique URNs in the collection
+ Assert.That(planEvent.Count, Is.AtLeast(1), "ScripingPlanNotificationParams.Count");
+ Assert.That(planEvent.ScriptingObjects.All(obj => obj.Name == "Customers" && obj.Schema == "dbo" && obj.Type == "Table"), "ScriptingPlanNotificationParams.ScriptingObjects contents");
}
}
- [Fact]
+ [Test]
public async Task ScriptTableDoesNotExist()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -211,13 +218,13 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingResult result = await testService.Script(requestParams);
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(15));
Assert.True(parameters.HasError);
- Assert.True(parameters.ErrorMessage.Contains("An error occurred while scripting the objects."));
- Assert.Contains("The Table '[dbo].[TableDoesNotExist]' does not exist on the server.", parameters.ErrorDetails);
+ Assert.That(parameters.ErrorMessage, Contains.Substring("An error occurred while scripting the objects."), "parameters.ErrorMessage");
+ Assert.That(parameters.ErrorDetails, Contains.Substring("The Table '[dbo].[TableDoesNotExist]' does not exist on the server."), "parameters.ErrorDetails");
}
}
- [Fact]
- public async void ScriptSchemaCancel()
+ [Test]
+ public async Task ScriptSchemaCancel()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
{
@@ -232,15 +239,15 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
};
var result = Task.Run(() => testService.Script(requestParams));
- ScriptingProgressNotificationParams progressParams = await testService.Driver.WaitForEvent(ScriptingProgressNotificationEvent.Type, TimeSpan.FromSeconds(10));
- Task.Run(() => testService.CancelScript(progressParams.OperationId).Wait());
+ ScriptingProgressNotificationParams progressParams = await testService.Driver.WaitForEvent(ScriptingProgressNotificationEvent.Type, TimeSpan.FromSeconds(60));
+ await Task.Run(() => testService.CancelScript(progressParams.OperationId));
ScriptingCompleteParams cancelEvent = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10));
Assert.True(cancelEvent.Canceled);
}
}
- [Fact]
+ [Test]
public async Task ScriptSchemaInvalidConnectionString()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -258,11 +265,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingResult result = await testService.Script(requestParams);
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10));
Assert.True(parameters.HasError);
- Assert.Equal("Error parsing ScriptingParams.ConnectionString property.", parameters.ErrorMessage);
+ Assert.AreEqual("Error parsing ScriptingParams.ConnectionString property.", parameters.ErrorMessage);
}
}
- [Fact]
+ [Test]
public async Task ScriptSchemaInvalidFilePath()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -280,11 +287,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
ScriptingResult result = await testService.Script(requestParams);
ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10));
Assert.True(parameters.HasError);
- Assert.Equal("Invalid directory specified by the ScriptingParams.FilePath property.", parameters.ErrorMessage);
+ Assert.AreEqual("Invalid directory specified by the ScriptingParams.FilePath property.", parameters.ErrorMessage);
}
}
- [Fact]
+ [Test]
public async Task ScriptSelectTable()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
@@ -359,7 +366,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
}
}
- public void Dispose() { }
public class ScriptingFixture : IDisposable
{
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/StressTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/StressTests.cs
index ee9a19a0..bb7af271 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/StressTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/StressTests.cs
@@ -5,21 +5,23 @@
using System;
using System.Diagnostics;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
using Range = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Range;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
+ [TestFixture]
public class StressTests
{
///
/// Simulate typing by a user to stress test the language service
///
- //[Fact]
+ //[Test]
public async Task TestLanguageService()
{
const string textToType = "SELECT * FROM sys.objects GO " +
@@ -144,7 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Repeatedly execute queries to stress test the query execution service.
///
- //[Fact]
+ //[Test]
public async Task TestQueryExecutionService()
{
const string queryToRun = "SELECT * FROM sys.all_objects GO " +
@@ -167,12 +169,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
var queryResult = await testService.RunQueryAndWaitToComplete(queryTempFile.FilePath, queryToRun, 10000);
Assert.NotNull(queryResult);
- Assert.NotNull(queryResult.BatchSummaries);
- Assert.NotEmpty(queryResult.BatchSummaries);
- Assert.NotNull(queryResult.BatchSummaries[0].ResultSetSummaries);
- Assert.NotNull(queryResult.BatchSummaries[1].ResultSetSummaries);
- Assert.NotNull(queryResult.BatchSummaries[2].ResultSetSummaries);
- Assert.NotNull(queryResult.BatchSummaries[3].ResultSetSummaries);
+ Assert.That(queryResult.BatchSummaries, Is.Not.Null, "queryResult.BatchSummaries");
+ Assert.That(queryResult.BatchSummaries.Select(b => b.ResultSetSummaries), Has.Exactly(4).Not.Null, "ResultSetSummaries in the queryResult");
Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 0, 0, 0, 7));
Assert.NotNull(await testService.ExecuteSubset(queryTempFile.FilePath, 1, 0, 0, 7));
@@ -189,7 +187,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Repeatedly connect and disconnect to stress test the connection service.
///
- //[Fact]
+ //[Test]
public async Task TestConnectionService()
{
string ownerUri = "file:///my/test/file.sql";
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/WorkspaceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/WorkspaceTests.cs
index 667bf955..569f7185 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/WorkspaceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests/WorkspaceTests.cs
@@ -7,10 +7,11 @@ using System.IO;
using System.Threading.Tasks;
using Microsoft.SqlTools.Hosting.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
{
+ [TestFixture]
///
/// Language Service end-to-end integration tests
///
@@ -19,7 +20,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Validate workspace lifecycle events
///
- [Fact]
+ [Test]
public async Task InitializeRequestTest()
{
using (TestServiceDriverProvider testService = new TestServiceDriverProvider())
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
index b715f668..8d6eea4f 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
@@ -49,9 +49,14 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
string serviceHostArguments = "--enable-logging";
if (string.IsNullOrWhiteSpace(serviceHostExecutable))
{
+
// Include a fallback value to for running tests within visual studio
serviceHostExecutable =
@"..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Debug\netcoreapp3.1\win7-x64\MicrosoftSqlToolsServiceLayer.exe";
+ if (!File.Exists(serviceHostExecutable))
+ {
+ serviceHostExecutable = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "MicrosoftSqlToolsServiceLayer.exe");
+ }
}
serviceHostExecutable = Path.GetFullPath(serviceHostExecutable);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Microsoft.SqlTools.ServiceLayer.TestDriver.csproj b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Microsoft.SqlTools.ServiceLayer.TestDriver.csproj
index 4be29f85..aa1df865 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Microsoft.SqlTools.ServiceLayer.TestDriver.csproj
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Microsoft.SqlTools.ServiceLayer.TestDriver.csproj
@@ -9,8 +9,6 @@
-
-
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Utility/TestRunner.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Utility/TestRunner.cs
index 9625b531..635692c1 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Utility/TestRunner.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Utility/TestRunner.cs
@@ -4,13 +4,7 @@
//
using System;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Reflection;
using System.Threading.Tasks;
-using Xunit;
-using Xunit.Sdk;
namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
{
@@ -95,90 +89,15 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Utility
public async Task RunTests(string[] args, string testNamespace)
{
ParseArguments(args);
- foreach (var test in Tests)
- {
- try
- {
- var testName = test.Contains(testNamespace) ? test.Replace(testNamespace, "") : test;
- bool containsTestName = testName.Contains(".");
- var className = containsTestName ? testName.Substring(0, testName.LastIndexOf('.')) : testName;
- var methodName = containsTestName ? testName.Substring(testName.LastIndexOf('.') + 1) : null;
- Assembly assembly = Assembly.GetEntryAssembly();
- Type type = assembly.GetType(testNamespace + className);
- if (type == null)
- {
- Console.WriteLine("Invalid class name");
- }
- else
- {
- var typeInstance = Activator.CreateInstance(type);
- if (string.IsNullOrEmpty(methodName))
- {
- var methods = type.GetMethods().Where(x => x.CustomAttributes.Any(a => a.AttributeType == typeof(FactAttribute)));
- foreach (var method in methods)
- {
- await RunTest(typeInstance, method, method.Name);
- }
- }
- else
- {
- MethodInfo methodInfo = type.GetMethod(methodName);
- await RunTest(typeInstance, methodInfo, test);
- }
-
- IDisposable disposable = typeInstance as IDisposable;
- if (disposable != null)
- {
- disposable.Dispose();
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- return -1;
- }
- }
- return 0;
- }
-
- private static async Task RunTest(object typeInstance, MethodInfo methodInfo, string testName)
- {
try
- {
- if (methodInfo == null)
- {
- Console.WriteLine("Invalid method name");
- }
- else
- {
- var testAttributes = methodInfo.CustomAttributes;
- BeforeAfterTestAttribute beforeAfterTestAttribute = null;
- foreach (var attribute in testAttributes)
- {
- var args = attribute.ConstructorArguments.Select(x => x.Value as object).ToArray();
- var objAttribute = Activator.CreateInstance(attribute.AttributeType, args);
-
- beforeAfterTestAttribute = objAttribute as BeforeAfterTestAttribute;
- if (beforeAfterTestAttribute != null)
- {
- beforeAfterTestAttribute.Before(methodInfo);
- }
- }
- Console.WriteLine("Running test " + testName);
- await (Task)methodInfo.Invoke(typeInstance, null);
- if (beforeAfterTestAttribute != null)
- {
- beforeAfterTestAttribute.After(methodInfo);
- }
- Console.WriteLine("Test ran successfully: " + testName);
- }
- }
- catch(Exception ex)
- {
- Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Test Failed: {0} error: {1}", testName, ex.Message));
-
- }
+ {
+ throw new NotImplementedException("This code needs to change to use 'dotnet test' or nunit directly");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.ToString());
+ return await Task.FromResult(-1);
+ }
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Admin/AdminServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Admin/AdminServiceTests.cs
index f7773f3d..bb5ce564 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Admin/AdminServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Admin/AdminServiceTests.cs
@@ -3,35 +3,31 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using System.Security;
-using Xunit;
-
-using Microsoft.SqlTools.ServiceLayer.Admin;
-using Microsoft.SqlTools.ServiceLayer.Connection;
-using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
+using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Management;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Admin
{
+ [TestFixture]
///
/// Tests for AdminService Class
///
public class AdminServiceTests
{
- [Fact]
+ [Test]
public void TestBuildingSecureStringFromPassword()
{
string password = "test_password";
var secureString = CDataContainer.BuildSecureStringFromPassword(password);
- Assert.Equal(password.Length, secureString.Length);
+ Assert.AreEqual(password.Length, secureString.Length);
}
- [Fact]
+ [Test]
public void TestBuildingSecureStringFromNullPassword()
{
string password = null;
var secureString = CDataContainer.BuildSecureStringFromPassword(password);
- Assert.Equal(0, secureString.Length);
+ Assert.AreEqual(0, secureString.Length);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AssemblyInfo.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AssemblyInfo.cs
index 70421c18..e87e98ec 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AssemblyInfo.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AssemblyInfo.cs
@@ -3,6 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using Xunit;
+using NUnit.Framework;
-[assembly: CollectionBehavior(DisableTestParallelization = true)]
+[assembly: NonParallelizable]
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AutoParameterization/SqlParameterizerTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AutoParameterization/SqlParameterizerTests.cs
index fab29d78..41edd0d3 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AutoParameterization/SqlParameterizerTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/AutoParameterization/SqlParameterizerTests.cs
@@ -12,12 +12,13 @@ using Microsoft.Data.SqlClient;
using Microsoft.SqlTools.ServiceLayer.AutoParameterizaition;
using Microsoft.SqlTools.ServiceLayer.AutoParameterizaition.Exceptions;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
using static System.Linq.Enumerable;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
{
+ [TestFixture]
///
/// Parameterization for Always Encrypted is a feature that automatically converts Transact-SQL variables
/// into query parameters (instances of SqlParameter Class). This allows the underlying .NET Framework
@@ -38,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// - Are declared and initialized in the same statement(inline initialization).
/// - Are initialized using a single literal.
///
- [Fact]
+ [Test]
public void SqlParameterizerShouldParameterizeValidVariables()
{
const string ssn = "795-73-9838";
@@ -56,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
DbCommand command = new SqlCommand { CommandText = sql };
command.Parameterize();
- Assert.Equal(expected: 3, actual: command.Parameters.Count);
+ Assert.AreEqual(expected: 3, actual: command.Parameters.Count);
}
///
@@ -67,7 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// The second is using a function used instead of a literal and so should not be parameterized.
/// The third is using an expression used instead of a literal and so should not be parameterized.
///
- [Fact]
+ [Test]
public void SqlParameterizerShouldNotParameterizeInvalidVariables()
{
string sql = $@"
@@ -82,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
DbCommand command = new SqlCommand { CommandText = sql };
command.Parameterize();
- Assert.Equal(expected: 0, actual: command.Parameters.Count);
+ Assert.AreEqual(expected: 0, actual: command.Parameters.Count);
}
///
@@ -90,7 +91,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// Batch statements larger than 300000 characters (Approximately 600 Kb) should
/// throw ParameterizationScriptTooLargeException.
///
- [Fact]
+ [Test]
public void SqlParameterizerShouldThrowWhenSqlIsTooLong()
{
@@ -118,7 +119,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// During parameterization, if we could not parse the SQL we will throw an ParameterizationParsingException.
/// Better to catch the error here than on the server.
///
- [Fact]
+ [Test]
public void SqlParameterizerShouldThrowWhenSqlIsInvalid()
{
string invalidSql = "THIS IS INVALID SQL";
@@ -135,7 +136,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// literal used for the initialization of the variable must also match the type in the variable declaration.
/// If not, a ParameterizationFormatException should get thrown.
///
- [Fact]
+ [Test]
public void SqlParameterizerShouldThrowWhenLiteralHasTypeMismatch()
{
// variable is declared an int but is getting set to character data
@@ -157,7 +158,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// the DbCommand object will throw an exception with the following message:
/// BeginExecuteReader: CommandText property has not been initialized
///
- [Fact]
+ [Test]
public void CommentOnlyBatchesShouldNotBeErasedFromCommandText()
{
string sql = $@"
@@ -169,7 +170,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
command.Parameterize();
Assert.False(string.IsNullOrEmpty(command.CommandText));
- Assert.Equal(expected: sql, actual: command.CommandText);
+ Assert.AreEqual(expected: sql, actual: command.CommandText);
}
#endregion
@@ -180,21 +181,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// When requesting a collection of ScriptFileMarker by calling the SqlParameterizer.CodeSense
/// method, if a null script is passed in, the reuslt should be an empty collection.
///
- [Fact]
+ [Test]
public void CodeSenseShouldReturnEmptyListWhenGivenANullScript()
{
string sql = null;
IList result = SqlParameterizer.CodeSense(sql);
Assert.NotNull(result);
- Assert.Empty(result);
+ Assert.That(result, Is.Empty);
}
///
/// When requesting a collection of ScriptFileMarker by calling the SqlParameterizer.CodeSense
/// method, if a script is passed in that contains no valid parameters, the reuslt should be an empty collection.
///
- [Fact]
+ [Test]
public void CodeSenseShouldReturnEmptyListWhenGivenAParameterlessScript()
{
// SQL with no parameters
@@ -206,7 +207,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
IList result = SqlParameterizer.CodeSense(sql);
Assert.NotNull(result);
- Assert.Empty(result);
+ Assert.That(result, Is.Empty);
}
///
@@ -214,7 +215,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// SQL statements larger than 300000 characters (Approximately 600 Kb) should
/// return a max string sength code sense item. These will be returned to ADS to display to the user as intelli-sense.
///
- [Fact]
+ [Test]
public void CodeSenseShouldReturnMaxStringLengthScriptFileMarkerErrorItemWhenScriptIsTooLong()
{
// SQL length of 300 characters
@@ -235,10 +236,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
Console.WriteLine(result[0].Message);
- Assert.NotEmpty(result);
- Assert.Equal(expected: 1, actual: result.Count);
- Assert.Equal(expected: ScriptFileMarkerLevel.Error, actual: result[0].Level);
- Assert.Equal(expected: expectedMessage, actual: result[0].Message);
+ Assert.That(result, Is.Not.Empty);
+ Assert.AreEqual(expected: 1, actual: result.Count);
+ Assert.AreEqual(expected: ScriptFileMarkerLevel.Error, actual: result[0].Level);
+ Assert.AreEqual(expected: expectedMessage, actual: result[0].Message);
}
///
@@ -246,7 +247,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
/// method, if a script is passed in that contains 3 valid parameters, the reuslt should be a collection of
/// three informational code sense items. These will be returned to ADS to display to the user as intelli-sense.
///
- [Fact]
+ [Test]
public void CodeSenseShouldReturnInformationalCodeSenseItemsForValidParameters()
{
const string ssn = "795-73-9838";
@@ -263,8 +264,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.AutoParameterization
IList result = SqlParameterizer.CodeSense(sql);
- Assert.NotEmpty(result);
- Assert.Equal(expected: 3, actual: result.Count);
+ Assert.That(result, Is.Not.Empty);
+ Assert.AreEqual(expected: 3, actual: result.Count);
Assert.True(Enumerable.All(result, i => i.Level == ScriptFileMarkerLevel.Information));
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/AutoCompletionResultTest.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/AutoCompletionResultTest.cs
index 87792656..4409f00a 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/AutoCompletionResultTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/AutoCompletionResultTest.cs
@@ -7,13 +7,14 @@
using System.Threading;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Completion
{
+ [TestFixture]
public class AutoCompletionResultTest
{
- [Fact]
+ [Test]
public void CompletionShouldRecordDuration()
{
AutoCompletionResult result = new AutoCompletionResult();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/ScriptDocumentInfoTest.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/ScriptDocumentInfoTest.cs
index fe65ed77..bc6d25c2 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/ScriptDocumentInfoTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Completion/ScriptDocumentInfoTest.cs
@@ -6,13 +6,14 @@
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Completion
{
+ [TestFixture]
public class ScriptDocumentInfoTest
{
- [Fact]
+ [Test]
public void MetricsShouldGetSortedGivenUnSortedArray()
{
TextDocumentPosition doc = new TextDocumentPosition()
@@ -35,11 +36,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Completion
ScriptParseInfo scriptParseInfo = new ScriptParseInfo();
ScriptDocumentInfo docInfo = new ScriptDocumentInfo(doc, scriptFile, scriptParseInfo);
- Assert.Equal(docInfo.StartLine, 1);
- Assert.Equal(docInfo.ParserLine, 2);
- Assert.Equal(docInfo.StartColumn, 44);
- Assert.Equal(docInfo.EndColumn, 14);
- Assert.Equal(docInfo.ParserColumn, 15);
+ Assert.AreEqual(1, docInfo.StartLine);
+ Assert.AreEqual(2, docInfo.ParserLine);
+ Assert.AreEqual(44, docInfo.StartColumn);
+ Assert.AreEqual(14, docInfo.EndColumn);
+ Assert.AreEqual(15, docInfo.ParserColumn);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/CachedServerInfoTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/CachedServerInfoTests.cs
index cf100c92..555fe4e1 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/CachedServerInfoTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/CachedServerInfoTests.cs
@@ -4,12 +4,13 @@
//
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
-using Xunit;
+using NUnit.Framework;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
+ [TestFixture]
///
/// Tests for Sever Information Caching Class
///
@@ -22,12 +23,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
cache = new CachedServerInfo();
}
- [Fact]
+ [Test]
public void CacheMatchesNullDbNameToEmptyString()
{
// Set sqlDw result into cache
- string dataSource = "testDataSource";
- DatabaseEngineEdition engineEdition;
+ string dataSource = "testDataSource";
SqlConnectionStringBuilder testSource = new SqlConnectionStringBuilder
{
DataSource = dataSource,
@@ -36,31 +36,26 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
cache.AddOrUpdateCache(testSource, DatabaseEngineEdition.SqlDataWarehouse, CachedServerInfo.CacheVariable.EngineEdition);
// Expect the same returned result
- Assert.Equal(cache.TryGetEngineEdition(testSource, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);
+ Assert.AreEqual(DatabaseEngineEdition.SqlDataWarehouse, cache.TryGetEngineEdition(testSource, out _));
// And expect the same for the null string
- Assert.Equal(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
+ Assert.AreEqual(DatabaseEngineEdition.SqlDataWarehouse, cache.TryGetEngineEdition(new SqlConnectionStringBuilder
{
DataSource = dataSource
// Initial Catalog is null. Can't set explicitly as this throws
- }, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);
+ }, out _));
- // But expect NotEqual for a different DB
- Assert.NotEqual(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
+ Assert.That(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
{
DataSource = dataSource,
InitialCatalog = "OtherDb"
- }, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);
+ }, out _), Is.Not.EqualTo(DatabaseEngineEdition.SqlDataWarehouse), "expect NotEqual for a different DB");
}
- [Theory]
- [InlineData(null, DatabaseEngineEdition.SqlDataWarehouse)] // is SqlDW instance
- [InlineData("", DatabaseEngineEdition.SqlDataWarehouse)] // is SqlDW instance
- [InlineData("myDb", DatabaseEngineEdition.SqlDataWarehouse)] // is SqlDW instance
- [InlineData(null, DatabaseEngineEdition.SqlOnDemand)] // is SqlOnDemand Instance
- [InlineData("", DatabaseEngineEdition.SqlOnDemand)] // is SqlOnDemand Instance
- [InlineData("myDb", DatabaseEngineEdition.SqlOnDemand)] // is SqlOnDemand instance
- public void AddOrUpdateEngineEditiopn(string dbName, DatabaseEngineEdition state)
+
+ [Test]
+ public void AddOrUpdateEngineEdition([Values(null, "", "myDb")] string dbName,
+ [Values(DatabaseEngineEdition.SqlDataWarehouse, DatabaseEngineEdition.SqlOnDemand)] DatabaseEngineEdition state)
{
// Set result into cache
DatabaseEngineEdition engineEdition;
@@ -75,15 +70,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
cache.AddOrUpdateCache(testSource, state, CachedServerInfo.CacheVariable.EngineEdition);
- // Expect the same returned result
- Assert.NotEqual(cache.TryGetEngineEdition(testSource, out engineEdition), DatabaseEngineEdition.Unknown);
- Assert.Equal(engineEdition, state);
+ Assert.Multiple(() =>
+ {
+ Assert.That(cache.TryGetEngineEdition(testSource, out engineEdition), Is.Not.EqualTo(DatabaseEngineEdition.Unknown) );
+ Assert.That(engineEdition, Is.EqualTo(state), "Expect the same returned result");
+ });
}
- [Theory]
- [InlineData(DatabaseEngineEdition.SqlDataWarehouse)] // is SqlDW instance
- [InlineData(DatabaseEngineEdition.SqlOnDemand)] // is SqlOnDemand Instance
- public void AddOrUpdateEngineEditionToggle(DatabaseEngineEdition state)
+ [Test]
+ public void AddOrUpdateEngineEditionToggle([Values(DatabaseEngineEdition.SqlDataWarehouse, DatabaseEngineEdition.SqlOnDemand)] DatabaseEngineEdition state)
{
// Set result into cache
DatabaseEngineEdition engineEdition;
@@ -93,21 +88,25 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
};
cache.AddOrUpdateCache(testSource, state, CachedServerInfo.CacheVariable.EngineEdition);
- // Expect the same returned result
- Assert.NotEqual(cache.TryGetEngineEdition(testSource, out engineEdition), DatabaseEngineEdition.Unknown);
- Assert.Equal(engineEdition, state);
+ Assert.Multiple(() =>
+ {
+ Assert.That(cache.TryGetEngineEdition(testSource, out engineEdition), Is.Not.EqualTo(DatabaseEngineEdition.Unknown));
+ Assert.That(engineEdition, Is.EqualTo(state), "Expect the same returned result");
+ });
DatabaseEngineEdition newState = state == DatabaseEngineEdition.SqlDataWarehouse ?
DatabaseEngineEdition.SqlOnDemand : DatabaseEngineEdition.SqlDataWarehouse;
cache.AddOrUpdateCache(testSource, newState, CachedServerInfo.CacheVariable.EngineEdition);
- // Expect the opposite returned result
- Assert.NotEqual(cache.TryGetEngineEdition(testSource, out engineEdition), DatabaseEngineEdition.Unknown);
- Assert.Equal(engineEdition, newState);
+ Assert.Multiple(() =>
+ {
+ Assert.That(cache.TryGetEngineEdition(testSource, out engineEdition), Is.Not.EqualTo(DatabaseEngineEdition.Unknown));
+ Assert.That(engineEdition, Is.EqualTo(newState), "Expect the opposite returned result");
+ });
}
- /* [Fact]
+ /* [Test]
public void AddOrUpdateIsSqlDwFalseToggle()
{
bool state = true;
@@ -142,22 +141,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.True(cache.TryGetIsSqlDw(differentServerSameDb, out isSqlDwResult3));
// Assert cache is set on a per connection basis
- Assert.Equal(isSqlDwResult, state);
- Assert.Equal(isSqlDwResult2, !state);
- Assert.Equal(isSqlDwResult3, !state);
+ Assert.AreEqual(isSqlDwResult, state);
+ Assert.AreEqual(isSqlDwResult2, !state);
+ Assert.AreEqual(isSqlDwResult3, !state);
}
*/
- [Fact]
+ [Test]
public void AskforEngineEditionBeforeCached()
- {
- DatabaseEngineEdition engineEdition;
- Assert.Equal(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
+ {
+ Assert.AreEqual(DatabaseEngineEdition.Unknown, cache.TryGetEngineEdition(new SqlConnectionStringBuilder
{
DataSource = "testDataSourceUnCached"
},
- out engineEdition), DatabaseEngineEdition.Unknown);
+ out _));
}
}
}
\ No newline at end of file
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionDetailsTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionDetailsTests.cs
index e29de8dd..c66ea43a 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionDetailsTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionDetailsTests.cs
@@ -6,17 +6,18 @@
using System.Linq;
using Microsoft.SqlTools.Hosting.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
-using Xunit;
+using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Connection;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
+ [TestFixture]
///
/// Tests for ConnectionDetails Class
///
public class ConnectionDetailsTests
{
- [Fact]
+ [Test]
public void ConnectionDetailsWithoutAnyOptionShouldReturnNullOrDefaultForOptions()
{
ConnectionDetails details = new ConnectionDetails();
@@ -25,39 +26,39 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
var expectedForInt = default(int?);
var expectedForBoolean = default(bool?);
- Assert.Equal(details.ApplicationIntent, expectedForStrings);
- Assert.Equal(details.ApplicationName, expectedForStrings);
- Assert.Equal(details.AttachDbFilename, expectedForStrings);
- Assert.Equal(details.AuthenticationType, expectedForStrings);
- Assert.Equal(details.CurrentLanguage, expectedForStrings);
- Assert.Equal(details.DatabaseName, expectedForStrings);
- Assert.Equal(details.FailoverPartner, expectedForStrings);
- Assert.Equal(details.Password, expectedForStrings);
- Assert.Equal(details.ServerName, expectedForStrings);
- Assert.Equal(details.TypeSystemVersion, expectedForStrings);
- Assert.Equal(details.UserName, expectedForStrings);
- Assert.Equal(details.WorkstationId, expectedForStrings);
- Assert.Equal(details.ConnectRetryInterval, expectedForInt);
- Assert.Equal(details.ConnectRetryCount, expectedForInt);
- Assert.Equal(details.ConnectTimeout, expectedForInt);
- Assert.Equal(details.LoadBalanceTimeout, expectedForInt);
- Assert.Equal(details.MaxPoolSize, expectedForInt);
- Assert.Equal(details.MinPoolSize, expectedForInt);
- Assert.Equal(details.PacketSize, expectedForInt);
- Assert.Equal(details.ColumnEncryptionSetting, expectedForStrings);
- Assert.Equal(details.EnclaveAttestationUrl, expectedForStrings);
- Assert.Equal(details.EnclaveAttestationProtocol, expectedForStrings);
- Assert.Equal(details.Encrypt, expectedForBoolean);
- Assert.Equal(details.MultipleActiveResultSets, expectedForBoolean);
- Assert.Equal(details.MultiSubnetFailover, expectedForBoolean);
- Assert.Equal(details.PersistSecurityInfo, expectedForBoolean);
- Assert.Equal(details.Pooling, expectedForBoolean);
- Assert.Equal(details.Replication, expectedForBoolean);
- Assert.Equal(details.TrustServerCertificate, expectedForBoolean);
- Assert.Equal(details.Port, expectedForInt);
+ Assert.AreEqual(details.ApplicationIntent, expectedForStrings);
+ Assert.AreEqual(details.ApplicationName, expectedForStrings);
+ Assert.AreEqual(details.AttachDbFilename, expectedForStrings);
+ Assert.AreEqual(details.AuthenticationType, expectedForStrings);
+ Assert.AreEqual(details.CurrentLanguage, expectedForStrings);
+ Assert.AreEqual(details.DatabaseName, expectedForStrings);
+ Assert.AreEqual(details.FailoverPartner, expectedForStrings);
+ Assert.AreEqual(details.Password, expectedForStrings);
+ Assert.AreEqual(details.ServerName, expectedForStrings);
+ Assert.AreEqual(details.TypeSystemVersion, expectedForStrings);
+ Assert.AreEqual(details.UserName, expectedForStrings);
+ Assert.AreEqual(details.WorkstationId, expectedForStrings);
+ Assert.AreEqual(details.ConnectRetryInterval, expectedForInt);
+ Assert.AreEqual(details.ConnectRetryCount, expectedForInt);
+ Assert.AreEqual(details.ConnectTimeout, expectedForInt);
+ Assert.AreEqual(details.LoadBalanceTimeout, expectedForInt);
+ Assert.AreEqual(details.MaxPoolSize, expectedForInt);
+ Assert.AreEqual(details.MinPoolSize, expectedForInt);
+ Assert.AreEqual(details.PacketSize, expectedForInt);
+ Assert.AreEqual(details.ColumnEncryptionSetting, expectedForStrings);
+ Assert.AreEqual(details.EnclaveAttestationUrl, expectedForStrings);
+ Assert.AreEqual(details.EnclaveAttestationProtocol, expectedForStrings);
+ Assert.AreEqual(details.Encrypt, expectedForBoolean);
+ Assert.AreEqual(details.MultipleActiveResultSets, expectedForBoolean);
+ Assert.AreEqual(details.MultiSubnetFailover, expectedForBoolean);
+ Assert.AreEqual(details.PersistSecurityInfo, expectedForBoolean);
+ Assert.AreEqual(details.Pooling, expectedForBoolean);
+ Assert.AreEqual(details.Replication, expectedForBoolean);
+ Assert.AreEqual(details.TrustServerCertificate, expectedForBoolean);
+ Assert.AreEqual(details.Port, expectedForInt);
}
- [Fact]
+ [Test]
public void ConnectionDetailsPropertySettersShouldSetOptionValuesCorrectly()
{
ConnectionDetails details = new ConnectionDetails();
@@ -97,39 +98,39 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
details.Port = expectedForInt + index++;
index = 0;
- Assert.Equal(details.ApplicationIntent, expectedForStrings + index++);
- Assert.Equal(details.ApplicationName, expectedForStrings + index++);
- Assert.Equal(details.AttachDbFilename, expectedForStrings + index++);
- Assert.Equal(details.AuthenticationType, expectedForStrings + index++);
- Assert.Equal(details.CurrentLanguage, expectedForStrings + index++);
- Assert.Equal(details.DatabaseName, expectedForStrings + index++);
- Assert.Equal(details.FailoverPartner, expectedForStrings + index++);
- Assert.Equal(details.Password, expectedForStrings + index++);
- Assert.Equal(details.ServerName, expectedForStrings + index++);
- Assert.Equal(details.TypeSystemVersion, expectedForStrings + index++);
- Assert.Equal(details.UserName, expectedForStrings + index++);
- Assert.Equal(details.WorkstationId, expectedForStrings + index++);
- Assert.Equal(details.ConnectRetryInterval, expectedForInt + index++);
- Assert.Equal(details.ConnectRetryCount, expectedForInt + index++);
- Assert.Equal(details.ConnectTimeout, expectedForInt + index++);
- Assert.Equal(details.LoadBalanceTimeout, expectedForInt + index++);
- Assert.Equal(details.MaxPoolSize, expectedForInt + index++);
- Assert.Equal(details.MinPoolSize, expectedForInt + index++);
- Assert.Equal(details.PacketSize, expectedForInt + index++);
- Assert.Equal(details.ColumnEncryptionSetting, expectedForStrings + index++);
- Assert.Equal(details.EnclaveAttestationProtocol, expectedForStrings + index++);
- Assert.Equal(details.EnclaveAttestationUrl, expectedForStrings + index++);
- Assert.Equal(details.Encrypt, (index++ % 2 == 0));
- Assert.Equal(details.MultipleActiveResultSets, (index++ % 2 == 0));
- Assert.Equal(details.MultiSubnetFailover, (index++ % 2 == 0));
- Assert.Equal(details.PersistSecurityInfo, (index++ % 2 == 0));
- Assert.Equal(details.Pooling, (index++ % 2 == 0));
- Assert.Equal(details.Replication, (index++ % 2 == 0));
- Assert.Equal(details.TrustServerCertificate, (index++ % 2 == 0));
- Assert.Equal(details.Port, (expectedForInt + index++));
+ Assert.AreEqual(details.ApplicationIntent, expectedForStrings + index++);
+ Assert.AreEqual(details.ApplicationName, expectedForStrings + index++);
+ Assert.AreEqual(details.AttachDbFilename, expectedForStrings + index++);
+ Assert.AreEqual(details.AuthenticationType, expectedForStrings + index++);
+ Assert.AreEqual(details.CurrentLanguage, expectedForStrings + index++);
+ Assert.AreEqual(details.DatabaseName, expectedForStrings + index++);
+ Assert.AreEqual(details.FailoverPartner, expectedForStrings + index++);
+ Assert.AreEqual(details.Password, expectedForStrings + index++);
+ Assert.AreEqual(details.ServerName, expectedForStrings + index++);
+ Assert.AreEqual(details.TypeSystemVersion, expectedForStrings + index++);
+ Assert.AreEqual(details.UserName, expectedForStrings + index++);
+ Assert.AreEqual(details.WorkstationId, expectedForStrings + index++);
+ Assert.AreEqual(details.ConnectRetryInterval, expectedForInt + index++);
+ Assert.AreEqual(details.ConnectRetryCount, expectedForInt + index++);
+ Assert.AreEqual(details.ConnectTimeout, expectedForInt + index++);
+ Assert.AreEqual(details.LoadBalanceTimeout, expectedForInt + index++);
+ Assert.AreEqual(details.MaxPoolSize, expectedForInt + index++);
+ Assert.AreEqual(details.MinPoolSize, expectedForInt + index++);
+ Assert.AreEqual(details.PacketSize, expectedForInt + index++);
+ Assert.AreEqual(details.ColumnEncryptionSetting, expectedForStrings + index++);
+ Assert.AreEqual(details.EnclaveAttestationProtocol, expectedForStrings + index++);
+ Assert.AreEqual(details.EnclaveAttestationUrl, expectedForStrings + index++);
+ Assert.AreEqual(details.Encrypt, (index++ % 2 == 0));
+ Assert.AreEqual(details.MultipleActiveResultSets, (index++ % 2 == 0));
+ Assert.AreEqual(details.MultiSubnetFailover, (index++ % 2 == 0));
+ Assert.AreEqual(details.PersistSecurityInfo, (index++ % 2 == 0));
+ Assert.AreEqual(details.Pooling, (index++ % 2 == 0));
+ Assert.AreEqual(details.Replication, (index++ % 2 == 0));
+ Assert.AreEqual(details.TrustServerCertificate, (index++ % 2 == 0));
+ Assert.AreEqual(details.Port, (expectedForInt + index++));
}
- [Fact]
+ [Test]
public void ConnectionDetailsOptionsShouldBeDefinedInConnectionProviderOptions()
{
ConnectionDetails details = new ConnectionDetails();
@@ -195,7 +196,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
}
- [Fact]
+ [Test]
public void SettingConnectiomTimeoutToLongShouldStillReturnInt()
{
ConnectionDetails details = new ConnectionDetails();
@@ -204,27 +205,27 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
int? expectedValue = 30;
details.Options["connectTimeout"] = timeout;
- Assert.Equal(details.ConnectTimeout, expectedValue);
+ Assert.AreEqual(details.ConnectTimeout, expectedValue);
}
- [Fact]
+ [Test]
public void ConnectTimeoutShouldReturnNullIfNotSet()
{
ConnectionDetails details = new ConnectionDetails();
int? expectedValue = null;
- Assert.Equal(details.ConnectTimeout, expectedValue);
+ Assert.AreEqual(details.ConnectTimeout, expectedValue);
}
- [Fact]
+ [Test]
public void ConnectTimeoutShouldReturnNullIfSetToNull()
{
ConnectionDetails details = new ConnectionDetails();
details.Options["connectTimeout"] = null;
int? expectedValue = null;
- Assert.Equal(details.ConnectTimeout, expectedValue);
+ Assert.AreEqual(details.ConnectTimeout, expectedValue);
}
- [Fact]
+ [Test]
public void SettingEncryptToStringShouldStillReturnBoolean()
{
ConnectionDetails details = new ConnectionDetails();
@@ -233,10 +234,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
bool? expectedValue = true;
details.Options["encrypt"] = encrypt;
- Assert.Equal(details.Encrypt, expectedValue);
+ Assert.AreEqual(details.Encrypt, expectedValue);
}
- [Fact]
+ [Test]
public void SettingEncryptToLowecaseStringShouldStillReturnBoolean()
{
ConnectionDetails details = new ConnectionDetails();
@@ -245,27 +246,27 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
bool? expectedValue = true;
details.Options["encrypt"] = encrypt;
- Assert.Equal(details.Encrypt, expectedValue);
+ Assert.AreEqual(details.Encrypt, expectedValue);
}
- [Fact]
+ [Test]
public void EncryptShouldReturnNullIfNotSet()
{
ConnectionDetails details = new ConnectionDetails();
bool? expectedValue = null;
- Assert.Equal(details.Encrypt, expectedValue);
+ Assert.AreEqual(details.Encrypt, expectedValue);
}
- [Fact]
+ [Test]
public void EncryptShouldReturnNullIfSetToNull()
{
ConnectionDetails details = new ConnectionDetails();
details.Options["encrypt"] = null;
int? expectedValue = null;
- Assert.Equal(details.ConnectTimeout, expectedValue);
+ Assert.AreEqual(details.ConnectTimeout, expectedValue);
}
- [Fact]
+ [Test]
public void SettingConnectiomTimeoutToLongWhichCannotBeConvertedToIntShouldNotCrash()
{
ConnectionDetails details = new ConnectionDetails();
@@ -275,8 +276,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
details.Options["connectTimeout"] = timeout;
details.Options["encrypt"] = true;
- Assert.Equal(details.ConnectTimeout, expectedValue);
- Assert.Equal(details.Encrypt, true);
+ Assert.AreEqual(details.ConnectTimeout, expectedValue);
+ Assert.AreEqual(true, details.Encrypt);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionServiceTests.cs
index 680b5433..185de1fe 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ConnectionServiceTests.cs
@@ -3,27 +3,28 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
using Microsoft.Data.SqlClient;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.SqlTools.Hosting.Protocol;
+using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
using Moq.Protected;
-using Xunit;
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
using System.Linq;
-using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
-
+using System.Reflection;
+using System.Threading;
+using System.Threading.Tasks;
+
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
+ [TestFixture]
///
/// Tests for the ServiceHost Connection Service tests
///
@@ -56,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
return connectionMock.Object;
}
- [Fact]
+ [Test]
public void CanCancelConnectRequest()
{
const string testFile = "file:///my/test/file.sql";
@@ -117,7 +118,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.True(cancelResult);
}
- [Fact]
+ [Test]
public async Task CanCancelConnectRequestByConnecting()
{
const string testFile = "file:///my/test/file.sql";
@@ -182,10 +183,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.Null(connectTask.Result.ConnectionId);
// Verify that the second connection succeeded
- Assert.NotEmpty(connectResult.ConnectionId);
+ Assert.That(connectResult.ConnectionId, Is.Not.Empty);
}
- [Fact]
+ [Test]
public void CanCancelConnectRequestByDisconnecting()
{
const string testFile = "file:///my/test/file.sql";
@@ -250,10 +251,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
/// Verify that we can connect to the default database when no database name is
/// provided as a parameter.
///
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- public async Task CanConnectWithEmptyDatabaseName(string databaseName)
+ [Test]
+ public async Task CanConnectWithEmptyDatabaseName([Values(null, "")]string databaseName)
{
// Connect
var connectionDetails = TestObjects.GetTestConnectionDetails();
@@ -266,18 +265,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = connectionDetails
});
- // check that a connection was created
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Empty, "check that a connection was created");
}
///
/// Verify that we can connect to the default database when no database name is
/// provided as a parameter.
///
- [Theory]
- [InlineData("master")]
- [InlineData("nonMasterDb")]
- public async Task ConnectToDefaultDatabaseRespondsWithActualDbName(string expectedDbName)
+ [Test]
+ public async Task ConnectToDefaultDatabaseRespondsWithActualDbName([Values("master", "nonMasterDb")]string expectedDbName)
{
// Given connecting with empty database name will return the expected DB name
var connectionMock = new Mock { CallBase = true };
@@ -301,17 +297,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = connectionDetails
});
- // Then I expect connection to succeed and the Summary to include the correct DB name
- Assert.NotEmpty(connectionResult.ConnectionId);
- Assert.NotNull(connectionResult.ConnectionSummary);
- Assert.Equal(expectedDbName, connectionResult.ConnectionSummary.DatabaseName);
+ Assert.Multiple(() =>
+ {
+ Assert.That(connectionResult.ConnectionId, Is.Not.Empty, "ConnectionId");
+ Assert.NotNull(connectionResult.ConnectionSummary, "ConnectionSummary");
+ Assert.AreEqual(expectedDbName, connectionResult.ConnectionSummary.DatabaseName, "I expect connection to succeed and the Summary to include the correct DB name");
+ });
}
///
/// Verify that when a connection is started for a URI with an already existing
/// connection, we disconnect first before connecting.
///
- [Fact]
+ [Test]
public async Task ConnectingWhenConnectionExistCausesDisconnectThenConnect()
{
bool callbackInvoked = false;
@@ -357,7 +355,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
});
// Then I expect to be connected to master
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// And when I then connect to another DB
var updatedConnectionDetails = TestObjects.GetTestConnectionDetails();
@@ -375,14 +373,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.True(callbackInvoked);
// verify that we connected again
- Assert.NotEmpty(connectionResult.ConnectionId);
- Assert.Equal(otherDbName, connectionResult.ConnectionSummary.DatabaseName);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
+ Assert.AreEqual(otherDbName, connectionResult.ConnectionSummary.DatabaseName);
}
///
/// Verify that when connecting with invalid credentials, an error is thrown.
///
- [Fact]
+ [Test]
public async Task ConnectingWithInvalidCredentialsYieldsErrorMessage()
{
var testConnectionDetails = TestObjects.GetTestConnectionDetails();
@@ -404,27 +402,28 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = invalidConnectionDetails
});
- // check that an error was caught
- Assert.NotNull(connectionResult.Messages);
- Assert.NotEqual(String.Empty, connectionResult.Messages);
+ Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
}
+ static readonly object[] invalidParameters =
+ {
+ new object[] { "SqlLogin", null, "my-server", "test", "sa", "123456" },
+ new object[] { "SqlLogin", "file://my/sample/file.sql", null, "test", "sa", "123456" },
+ new object[] {"SqlLogin", "file://my/sample/file.sql", "my-server", "test", null, "123456"},
+ new object[] {"SqlLogin", "file://my/sample/file.sql", "my-server", "test", "sa", null},
+ new object[] {"SqlLogin", "", "my-server", "test", "sa", "123456" },
+ new object[] {"SqlLogin", "file://my/sample/file.sql", "", "test", "sa", "123456"},
+ new object[] {"SqlLogin", "file://my/sample/file.sql", "my-server", "test", "", "123456"},
+ new object[] {"SqlLogin", "file://my/sample/file.sql", "my-server", "test", "sa", ""},
+ new object[] {"Integrated", null, "my-server", "test", "sa", "123456"},
+ new object[] {"Integrated", "file://my/sample/file.sql", null, "test", "sa", "123456"},
+ new object[] {"Integrated", "", "my-server", "test", "sa", "123456"},
+ new object[] {"Integrated", "file://my/sample/file.sql", "", "test", "sa", "123456"}
+ };
///
/// Verify that when connecting with invalid parameters, an error is thrown.
///
- [Theory]
- [InlineData("SqlLogin", null, "my-server", "test", "sa", "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", null, "test", "sa", "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", "my-server", "test", null, "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", "my-server", "test", "sa", null)]
- [InlineData("SqlLogin", "", "my-server", "test", "sa", "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", "", "test", "sa", "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", "my-server", "test", "", "123456")]
- [InlineData("SqlLogin", "file://my/sample/file.sql", "my-server", "test", "sa", "")]
- [InlineData("Integrated", null, "my-server", "test", "sa", "123456")]
- [InlineData("Integrated", "file://my/sample/file.sql", null, "test", "sa", "123456")]
- [InlineData("Integrated", "", "my-server", "test", "sa", "123456")]
- [InlineData("Integrated", "file://my/sample/file.sql", "", "test", "sa", "123456")]
+ [Test, TestCaseSource(nameof(invalidParameters))]
public async Task ConnectingWithInvalidParametersYieldsErrorMessage(string authType, string ownerUri, string server, string database, string userName, string password)
{
// Connect with invalid parameters
@@ -443,23 +442,24 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
}
});
- // check that an error was caught
- Assert.NotNull(connectionResult.Messages);
- Assert.NotEqual(String.Empty, connectionResult.Messages);
+ Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
}
+ static readonly object[] noUserNameOrPassword =
+ {
+ new object[] {null, null},
+ new object[] {null, ""},
+ new object[] {"", null},
+ new object[] {"", ""},
+ new object[] {"sa", null},
+ new object[] {"sa", ""},
+ new object[] {null, "12345678"},
+ new object[] {"", "12345678"},
+ };
///
/// Verify that when using integrated authentication, the username and/or password can be empty.
///
- [Theory]
- [InlineData(null, null)]
- [InlineData(null, "")]
- [InlineData("", null)]
- [InlineData("", "")]
- [InlineData("sa", null)]
- [InlineData("sa", "")]
- [InlineData(null, "12345678")]
- [InlineData("", "12345678")]
+ [Test, TestCaseSource(nameof(noUserNameOrPassword))]
public async Task ConnectingWithNoUsernameOrPasswordWorksForIntegratedAuth(string userName, string password)
{
// Connect
@@ -478,14 +478,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
}
});
- // check that the connection was successful
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
}
///
/// Verify that when connecting with a null parameters object, an error is thrown.
///
- [Fact]
+ [Test]
public async Task ConnectingWithNullParametersObjectYieldsErrorMessage()
{
// Connect with null parameters
@@ -493,54 +492,57 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
TestObjects.GetTestConnectionService()
.Connect(null);
- // check that an error was caught
- Assert.NotNull(connectionResult.Messages);
- Assert.NotEqual(String.Empty, connectionResult.Messages);
+ Assert.That(connectionResult.Messages, Is.Not.Null.Or.Empty, "check that an error was caught");
}
+
+ private static readonly object[] optionalParameters =
+ {
+ new object[] {"AuthenticationType", "Integrated", "Integrated Security" },
+ new object[] {"AuthenticationType", "SqlLogin", ""},
+ new object[] {"Encrypt", true, "Encrypt"},
+ new object[] {"Encrypt", false, "Encrypt"},
+ new object[] {"ColumnEncryptionSetting", "Enabled", "Column Encryption Setting=Enabled"},
+ new object[] {"ColumnEncryptionSetting", "Disabled", "Column Encryption Setting=Disabled"},
+ new object[] {"ColumnEncryptionSetting", "enabled", "Column Encryption Setting=Enabled"},
+ new object[] {"ColumnEncryptionSetting", "disabled", "Column Encryption Setting=Disabled"},
+ new object[] {"ColumnEncryptionSetting", "ENABLED", "Column Encryption Setting=Enabled"},
+ new object[] {"ColumnEncryptionSetting", "DISABLED", "Column Encryption Setting=Disabled"},
+ new object[] {"ColumnEncryptionSetting", "eNaBlEd", "Column Encryption Setting=Enabled"},
+ new object[] {"ColumnEncryptionSetting", "DiSaBlEd", "Column Encryption Setting=Disabled"},
+ new object[] {"TrustServerCertificate", true, "Trust Server Certificate"},
+ new object[] {"TrustServerCertificate", false, "Trust Server Certificate"},
+ new object[] {"PersistSecurityInfo", true, "Persist Security Info"},
+ new object[] {"PersistSecurityInfo", false, "Persist Security Info"},
+ new object[] {"ConnectTimeout", 15, "Connect Timeout"},
+ new object[] {"ConnectRetryCount", 1, "Connect Retry Count"},
+ new object[] {"ConnectRetryInterval", 10, "Connect Retry Interval"},
+ new object[] {"ApplicationName", "vscode-mssql", "Application Name"},
+ new object[] {"WorkstationId", "mycomputer", "Workstation ID"},
+ new object[] {"ApplicationIntent", "ReadWrite", "Application Intent"},
+ new object[] {"ApplicationIntent", "ReadOnly", "Application Intent"},
+ new object[] {"CurrentLanguage", "test", "Current Language"},
+ new object[] {"Pooling", false, "Pooling"},
+ new object[] {"Pooling", true, "Pooling"},
+ new object[] {"MaxPoolSize", 100, "Max Pool Size"},
+ new object[] {"MinPoolSize", 0, "Min Pool Size"},
+ new object[] {"LoadBalanceTimeout", 0, "Load Balance Timeout"},
+ new object[] {"Replication", true, "Replication"},
+ new object[] {"Replication", false, "Replication"},
+ new object[] {"AttachDbFilename", "myfile", "AttachDbFilename"},
+ new object[] {"FailoverPartner", "partner", "Failover Partner"},
+ new object[] {"MultiSubnetFailover", true, "Multi Subnet Failover"},
+ new object[] {"MultiSubnetFailover", false, "Multi Subnet Failover"},
+ new object[] {"MultipleActiveResultSets", false, "Multiple Active Result Sets"},
+ new object[] {"MultipleActiveResultSets", true, "Multiple Active Result Sets"},
+ new object[] {"PacketSize", 8192, "Packet Size"},
+ new object[] {"TypeSystemVersion", "Latest", "Type System Version"},
+ };
+
///
/// Verify that optional parameters can be built into a connection string for connecting.
///
- [Theory]
- [InlineData("AuthenticationType", "Integrated", "Integrated Security")]
- [InlineData("AuthenticationType", "SqlLogin", "")]
- [InlineData("Encrypt", true, "Encrypt")]
- [InlineData("Encrypt", false, "Encrypt")]
- [InlineData("ColumnEncryptionSetting", "Enabled", "Column Encryption Setting=Enabled")]
- [InlineData("ColumnEncryptionSetting", "Disabled", "Column Encryption Setting=Disabled")]
- [InlineData("ColumnEncryptionSetting", "enabled", "Column Encryption Setting=Enabled")]
- [InlineData("ColumnEncryptionSetting", "disabled", "Column Encryption Setting=Disabled")]
- [InlineData("ColumnEncryptionSetting", "ENABLED", "Column Encryption Setting=Enabled")]
- [InlineData("ColumnEncryptionSetting", "DISABLED", "Column Encryption Setting=Disabled")]
- [InlineData("ColumnEncryptionSetting", "eNaBlEd", "Column Encryption Setting=Enabled")]
- [InlineData("ColumnEncryptionSetting", "DiSaBlEd", "Column Encryption Setting=Disabled")]
- [InlineData("TrustServerCertificate", true, "Trust Server Certificate")]
- [InlineData("TrustServerCertificate", false, "Trust Server Certificate")]
- [InlineData("PersistSecurityInfo", true, "Persist Security Info")]
- [InlineData("PersistSecurityInfo", false, "Persist Security Info")]
- [InlineData("ConnectTimeout", 15, "Connect Timeout")]
- [InlineData("ConnectRetryCount", 1, "Connect Retry Count")]
- [InlineData("ConnectRetryInterval", 10, "Connect Retry Interval")]
- [InlineData("ApplicationName", "vscode-mssql", "Application Name")]
- [InlineData("WorkstationId", "mycomputer", "Workstation ID")]
- [InlineData("ApplicationIntent", "ReadWrite", "Application Intent")]
- [InlineData("ApplicationIntent", "ReadOnly", "Application Intent")]
- [InlineData("CurrentLanguage", "test", "Current Language")]
- [InlineData("Pooling", false, "Pooling")]
- [InlineData("Pooling", true, "Pooling")]
- [InlineData("MaxPoolSize", 100, "Max Pool Size")]
- [InlineData("MinPoolSize", 0, "Min Pool Size")]
- [InlineData("LoadBalanceTimeout", 0, "Load Balance Timeout")]
- [InlineData("Replication", true, "Replication")]
- [InlineData("Replication", false, "Replication")]
- [InlineData("AttachDbFilename", "myfile", "AttachDbFilename")]
- [InlineData("FailoverPartner", "partner", "Failover Partner")]
- [InlineData("MultiSubnetFailover", true, "Multi Subnet Failover")]
- [InlineData("MultiSubnetFailover", false, "Multi Subnet Failover")]
- [InlineData("MultipleActiveResultSets", false, "Multiple Active Result Sets")]
- [InlineData("MultipleActiveResultSets", true, "Multiple Active Result Sets")]
- [InlineData("PacketSize", 8192, "Packet Size")]
- [InlineData("TypeSystemVersion", "Latest", "Type System Version")]
+ [Test, TestCaseSource(nameof(optionalParameters))]
public void ConnectingWithOptionalParametersBuildsConnectionString(string propertyName, object propertyValue, string connectionStringMarker)
{
// Create a test connection details object and set the property to a specific value
@@ -550,52 +552,50 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// Test that a connection string can be created without exceptions
string connectionString = ConnectionService.BuildConnectionString(details);
- Assert.NotNull(connectionString);
- Assert.NotEmpty(connectionString);
- // Verify that the parameter is in the connection string
- Assert.True(connectionString.Contains(connectionStringMarker));
+ Assert.That(connectionString, Contains.Substring(connectionStringMarker), "Verify that the parameter is in the connection string");
}
+ private static readonly object[] optionalEnclaveParameters =
+ {
+ new object[] {"EnclaveAttestationProtocol", "AAS", "Attestation Protocol=AAS"},
+ new object[] {"EnclaveAttestationProtocol", "HGS", "Attestation Protocol=HGS"},
+ new object[] {"EnclaveAttestationProtocol", "aas", "Attestation Protocol=AAS"},
+ new object[] {"EnclaveAttestationProtocol", "hgs", "Attestation Protocol=HGS"},
+ new object[] {"EnclaveAttestationProtocol", "AaS", "Attestation Protocol=AAS"},
+ new object[] {"EnclaveAttestationProtocol", "hGs", "Attestation Protocol=HGS"},
+ new object[] {"EnclaveAttestationUrl", "https://attestation.us.attest.azure.net/attest/SgxEnclave", "Enclave Attestation Url=https://attestation.us.attest.azure.net/attest/SgxEnclave" },
+ };
+
///
/// Verify that optional parameters which require ColumnEncryptionSetting to be enabled
/// can be built into a connection string for connecting.
///
- [Theory]
- [InlineData("EnclaveAttestationProtocol", "AAS", "Attestation Protocol=AAS")]
- [InlineData("EnclaveAttestationProtocol", "HGS", "Attestation Protocol=HGS")]
- [InlineData("EnclaveAttestationProtocol", "aas", "Attestation Protocol=AAS")]
- [InlineData("EnclaveAttestationProtocol", "hgs", "Attestation Protocol=HGS")]
- [InlineData("EnclaveAttestationProtocol", "AaS", "Attestation Protocol=AAS")]
- [InlineData("EnclaveAttestationProtocol", "hGs", "Attestation Protocol=HGS")]
- [InlineData("EnclaveAttestationUrl", "https://attestation.us.attest.azure.net/attest/SgxEnclave", "Enclave Attestation Url=https://attestation.us.attest.azure.net/attest/SgxEnclave")]
+ [Test, TestCaseSource(nameof(optionalEnclaveParameters))]
public void ConnectingWithOptionalEnclaveParametersBuildsConnectionString(string propertyName, object propertyValue, string connectionStringMarker)
{
// Create a test connection details object and set the property to a specific value
ConnectionDetails details = TestObjects.GetTestConnectionDetails();
- details.GetType()
- .GetProperty("ColumnEncryptionSetting")
- .SetValue(details, "Enabled");
+ details.ColumnEncryptionSetting = "Enabled";
details.GetType()
.GetProperty(propertyName)
.SetValue(details, propertyValue);
// Test that a connection string can be created without exceptions
- string connectionString = ConnectionService.BuildConnectionString(details);
- Assert.NotNull(connectionString);
- Assert.NotEmpty(connectionString);
-
- // Verify that the parameter is in the connection string
- Assert.True(connectionString.Contains(connectionStringMarker));
+ string connectionString = ConnectionService.BuildConnectionString(details);
+ Assert.That(connectionString, Contains.Substring(connectionStringMarker), "Verify that the parameter is in the connection string");
}
+ private static readonly object[] invalidOptions =
+ {
+ new object[] {"AuthenticationType", "NotAValidAuthType" },
+ new object[] {"ColumnEncryptionSetting", "NotAValidColumnEncryptionSetting" },
+ new object[] {"EnclaveAttestationProtocol", "NotAValidEnclaveAttestationProtocol" },
+ };
///
/// Build connection string with an invalid property type
///
- [Theory]
- [InlineData("AuthenticationType", "NotAValidAuthType")]
- [InlineData("ColumnEncryptionSetting", "NotAValidColumnEncryptionSetting")]
- [InlineData("EnclaveAttestationProtocol", "NotAValidEnclaveAttestationProtocol")]
+ [Test, TestCaseSource(nameof(invalidOptions))]
public void BuildConnectionStringWithInvalidOptions(string propertyName, object propertyValue)
{
ConnectionDetails details = TestObjects.GetTestConnectionDetails();
@@ -604,63 +604,50 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.Throws(() => ConnectionService.BuildConnectionString(details));
}
- ///
- /// Parameters used for test: BuildConnectionStringWithInvalidOptionCombinations
- ///
- public static readonly object[][] ConnectionStringWithInvalidOptionCombinations =
- {
- new object[]
- {
- typeof(ArgumentException),
- new []
+ private static readonly Tuple[][] optionCombos =
+ {
+ new []
{
Tuple.Create("ColumnEncryptionSetting", null),
Tuple.Create("EnclaveAttestationProtocol", "AAS"),
Tuple.Create("EnclaveAttestationUrl", "https://attestation.us.attest.azure.net/attest/SgxEnclave")
- }
- },
- new object[]
- {
- typeof(ArgumentException),
- new []
+ },
+ new []
{
Tuple.Create("ColumnEncryptionSetting", "Disabled"),
Tuple.Create("EnclaveAttestationProtocol", "AAS"),
Tuple.Create("EnclaveAttestationUrl", "https://attestation.us.attest.azure.net/attest/SgxEnclave")
- }
- },
- new object[]
- {
- typeof(ArgumentException),
- new []
+ },
+ new []
{
Tuple.Create("ColumnEncryptionSetting", ""),
Tuple.Create("EnclaveAttestationProtocol", "AAS"),
Tuple.Create("EnclaveAttestationUrl", "https://attestation.us.attest.azure.net/attest/SgxEnclave")
- }
- }
+ }
};
///
/// Build connection string with an invalid property combinations
///
- [Theory]
- [MemberData(nameof(ConnectionStringWithInvalidOptionCombinations))]
- public void BuildConnectionStringWithInvalidOptionCombinations(Type exceptionType, Tuple[] propertyNameValuePairs)
+ [Test]
+ public void ConnStrWithInvalidOptions()
{
ConnectionDetails details = TestObjects.GetTestConnectionDetails();
- propertyNameValuePairs.ToList().ForEach(tuple =>
- {
- PropertyInfo info = details.GetType().GetProperty(tuple.Item1);
- info.SetValue(details, tuple.Item2);
- });
- Assert.Throws(exceptionType, () => ConnectionService.BuildConnectionString(details));
+ foreach (var options in optionCombos)
+ {
+ options.ToList().ForEach(tuple =>
+ {
+ PropertyInfo info = details.GetType().GetProperty(tuple.Item1);
+ info.SetValue(details, tuple.Item2);
+ });
+ Assert.Throws(() => ConnectionService.BuildConnectionString(details));
+ }
}
///
/// Verify that a connection changed event is fired when the database context changes.
///
- [Fact]
+ [Test]
public async Task ConnectionChangedEventIsFiredWhenDatabaseContextChanges()
{
var serviceHostMock = new Mock();
@@ -678,8 +665,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = TestObjects.GetTestConnectionDetails()
});
- // verify that a valid connection id was returned
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Empty, "verify that a valid connection id was returned");
ConnectionInfo info;
Assert.True(connectionService.TryFindConnection(ownerUri, out info));
@@ -694,7 +680,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Verify that the SQL parser correctly detects errors in text
///
- [Fact]
+ [Test]
public async Task ConnectToDatabaseTest()
{
// connect to a database instance
@@ -707,14 +693,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = TestObjects.GetTestConnectionDetails()
});
- // verify that a valid connection id was returned
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
}
///
/// Verify that we can disconnect from an active connection successfully
///
- [Fact]
+ [Test]
public async Task DisconnectFromDatabaseTest()
{
// first connect
@@ -728,8 +713,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = TestObjects.GetTestConnectionDetails()
});
- // verify that we are connected
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// send disconnect request
var disconnectResult =
@@ -744,7 +728,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that when a disconnect is performed, the callback event is fired
///
- [Fact]
+ [Test]
public async Task DisconnectFiresCallbackEvent()
{
bool callbackInvoked = false;
@@ -760,8 +744,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Connection = TestObjects.GetTestConnectionDetails()
});
- // verify that we are connected
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// register disconnect callback
connectionService.RegisterOnDisconnectTask(
@@ -789,7 +772,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that disconnecting an active connection removes the Owner URI -> ConnectionInfo mapping
///
- [Fact]
+ [Test]
public async Task DisconnectRemovesOwnerMapping()
{
// first connect
@@ -804,7 +787,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
});
// verify that we are connected
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// check that the owner mapping exists
ConnectionInfo info;
@@ -826,11 +809,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that disconnecting validates parameters and doesn't succeed when they are invalid
///
- [Theory]
- [InlineData(null)]
- [InlineData("")]
-
- public async Task DisconnectValidatesParameters(string disconnectUri)
+ [Test]
+ public async Task DisconnectValidatesParameters([Values("", null)] string disconnectUri)
{
// first connect
string ownerUri = "file://my/sample/file.sql";
@@ -844,7 +824,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
});
// verify that we are connected
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// send disconnect request
var disconnectResult =
@@ -877,7 +857,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
});
// verify that a valid connection id was returned
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
// list databases for the connection
ListDatabasesParams parameters = new ListDatabasesParams
@@ -891,7 +871,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Verifies the the list databases operation lists database names for the server used by a connection.
///
- [Fact]
+ [Test]
public async Task ListDatabasesOnServerForCurrentConnectionReturnsDatabaseNames()
{
// Result set for the query of database names
@@ -909,18 +889,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
string[] databaseNames = response.DatabaseNames;
- Assert.Equal(databaseNames.Length, 5);
- Assert.Equal(databaseNames[0], "master");
- Assert.Equal(databaseNames[1], "model");
- Assert.Equal(databaseNames[2], "msdb");
- Assert.Equal(databaseNames[3], "tempdb");
- Assert.Equal(databaseNames[4], "mydatabase");
+ Assert.AreEqual(5, databaseNames.Length);
+ Assert.AreEqual("master", databaseNames[0]);
+ Assert.AreEqual("model", databaseNames[1]);
+ Assert.AreEqual("msdb", databaseNames[2]);
+ Assert.AreEqual("tempdb", databaseNames[3]);
+ Assert.AreEqual("mydatabase", databaseNames[4]);
}
///
/// Verifies the the list databases operation lists database names for the server used by a connection.
///
- [Fact]
+ [Test]
public async Task ListDatabasesOnServerForCurrentConnectionReturnsDatabaseDetails()
{
// Result set for the query of database names
@@ -941,7 +921,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
TestResultSet data = new TestResultSet(cols, rows);
var response = await RunListDatabasesRequestHandler(testdata: data, includeDetails: true);
- Assert.Equal(response.Databases.Length, 5);
+ Assert.AreEqual(5, response.Databases.Length);
VerifyDatabaseDetail(rows[0], response.Databases[4]);
VerifyDatabaseDetail(rows[1], response.Databases[0]);
VerifyDatabaseDetail(rows[2], response.Databases[1]);
@@ -951,49 +931,49 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
private void VerifyDatabaseDetail(object[] expected, DatabaseInfo actual)
{
- Assert.Equal(expected[0], actual.Options[ListDatabasesRequestDatabaseProperties.Name]);
- Assert.Equal(expected[1], actual.Options[ListDatabasesRequestDatabaseProperties.State]);
- Assert.Equal(expected[2], actual.Options[ListDatabasesRequestDatabaseProperties.SizeInMB]);
- Assert.Equal(expected[3], actual.Options[ListDatabasesRequestDatabaseProperties.LastBackup]);
+ Assert.AreEqual(expected[0], actual.Options[ListDatabasesRequestDatabaseProperties.Name]);
+ Assert.AreEqual(expected[1], actual.Options[ListDatabasesRequestDatabaseProperties.State]);
+ Assert.AreEqual(expected[2], actual.Options[ListDatabasesRequestDatabaseProperties.SizeInMB]);
+ Assert.AreEqual(expected[3], actual.Options[ListDatabasesRequestDatabaseProperties.LastBackup]);
}
///
/// Verify that the factory is returning DatabaseNamesHandler
///
- [Fact]
+ [Test]
public void ListDatabaseRequestFactoryReturnsDatabaseNamesHandler()
{
var handler = ListDatabaseRequestHandlerFactory.getHandler(includeDetails: false, isSqlDB: true);
- Assert.IsType(typeof(DatabaseNamesHandler), handler);
+ Assert.That(handler, Is.InstanceOf());
handler = ListDatabaseRequestHandlerFactory.getHandler(includeDetails: false, isSqlDB: false);
- Assert.IsType(typeof(DatabaseNamesHandler), handler);
+ Assert.That(handler, Is.InstanceOf());
}
///
/// Verify that the factory is returning SqlDBDatabaseDetailHandler
///
- [Fact]
+ [Test]
public void ListDatabaseRequestFactoryReturnsSqlDBHandler()
{
var handler = ListDatabaseRequestHandlerFactory.getHandler(includeDetails: true, isSqlDB: true);
- Assert.IsType(typeof(SqlDBDatabaseDetailHandler), handler);
+ Assert.That(handler, Is.InstanceOf());
}
///
/// Verify that the factory is returning SqlServerDatabaseDetailHandler
///
- [Fact]
+ [Test]
public void ListDatabaseRequestFactoryReturnsSqlServerHandler()
{
var handler = ListDatabaseRequestHandlerFactory.getHandler(includeDetails: true, isSqlDB: false);
- Assert.IsType(typeof(SqlServerDatabaseDetailHandler), handler);
+ Assert.That(handler, Is.InstanceOf());
}
///
/// Verify that the SQL parser correctly detects errors in text
///
- [Fact]
+ [Test]
public async Task OnConnectionCallbackHandlerTest()
{
bool callbackInvoked = false;
@@ -1018,7 +998,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test ConnectionSummaryComparer
///
- [Fact]
+ [Test]
public void TestConnectionSummaryComparer()
{
var summary1 = new ConnectionSummary()
@@ -1048,7 +1028,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Verify when a connection is created that the URI -> Connection mapping is created in the connection service.
///
- [Fact]
+ [Test]
public async Task TestConnectRequestRegistersOwner()
{
// Given a request to connect to a database
@@ -1060,7 +1040,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// verify that a valid connection id was returned
Assert.NotNull(connectionResult.ConnectionId);
- Assert.NotEqual(string.Empty, connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.EqualTo(string.Empty));
Assert.NotNull(new Guid(connectionResult.ConnectionId));
// verify that the (URI -> connection) mapping was created
@@ -1075,7 +1055,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
/// the case, look at RetryPolicyUtils.cs in IsRetryableNetworkConnectivityError(),
/// and remove the code block specific to Linux/OSX.
///
- [Fact]
+ [Test]
public void TestThatLinuxAndOsxSqlExceptionHasNoErrorCode()
{
RunIfWrapper.RunIfLinuxOrOSX(() =>
@@ -1095,7 +1075,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
catch (SqlException ex)
{
// Error code should be 0 due to bug
- Assert.Equal(ex.Number, 0);
+ Assert.AreEqual(0, ex.Number);
}
});
}
@@ -1103,7 +1083,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that cancel connection with a null connection parameter
///
- [Fact]
+ [Test]
public void TestCancelConnectionNullParam()
{
var service = TestObjects.GetTestConnectionService();
@@ -1113,7 +1093,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that cancel connection with a null connection parameter
///
- [Fact]
+ [Test]
public void TestListDatabasesInvalidParams()
{
var service = TestObjects.GetTestConnectionService();
@@ -1126,7 +1106,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that the connection complete notification type can be created.
///
- [Fact]
+ [Test]
public void TestConnectionCompleteNotificationIsCreated()
{
Assert.NotNull(ConnectionCompleteNotification.Type);
@@ -1135,17 +1115,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
///
/// Test that the connection summary comparer creates a hash code correctly
///
- [Theory]
- [InlineData(true, null, null, null)]
- [InlineData(false, null, null, null)]
- [InlineData(false, null, null, "sa")]
- [InlineData(false, null, "test", null)]
- [InlineData(false, null, "test", "sa")]
- [InlineData(false, "server", null, null)]
- [InlineData(false, "server", null, "sa")]
- [InlineData(false, "server", "test", null)]
- [InlineData(false, "server", "test", "sa")]
- public void TestConnectionSummaryComparerHashCode(bool objectNull, string serverName, string databaseName, string userName)
+ [Test]
+ public void TestConnectionSummaryComparerHashCode([Values]bool objectNull,
+ [Values(null, "server")]string serverName,
+ [Values(null, "test")]string databaseName,
+ [Values(null, "sa")]string userName)
{
// Given a connection summary and comparer object
ConnectionSummary summary = null;
@@ -1164,17 +1138,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
int hashCode = comparer.GetHashCode(summary);
if (summary == null || (serverName == null && databaseName == null && userName == null))
{
- // Then I expect it to be 31 for a null summary
- Assert.Equal(31, hashCode);
+ Assert.AreEqual(31, hashCode, "I expect it to be 31 for a null summary");
}
else
{
- // And not 31 otherwise
- Assert.NotEqual(31, hashCode);
+ Assert.That(hashCode, Is.Not.EqualTo(31), "And not 31 otherwise");
}
}
- [Fact]
+ [Test]
public void ConnectParamsAreInvalidIfConnectionIsNull()
{
// Given connection parameters where the connection property is null
@@ -1189,13 +1161,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// If I check if the parameters are valid
Assert.False(parameters.IsValid(out errorMessage));
- // Then I expect an error message
- Assert.NotNull(errorMessage);
- Assert.NotEmpty(errorMessage);
+ Assert.That(errorMessage, Is.Not.Null.Or.Empty, "Then I expect an error message");
}
- [Fact]
- public async void ConnectingTwiceWithTheSameUriDoesNotCreateAnotherDbConnection()
+ [Test]
+ public async Task ConnectingTwiceWithTheSameUriDoesNotCreateAnotherDbConnection()
{
// Setup the connect and disconnect params
var connectParamsSame1 = new ConnectParams()
@@ -1225,31 +1195,31 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// Given a request to connect to a database, there should be no initial connections in the map
var service = TestObjects.GetTestConnectionService();
Dictionary ownerToConnectionMap = service.OwnerToConnectionMap;
- Assert.Equal(0, ownerToConnectionMap.Count);
+ Assert.AreEqual(0, ownerToConnectionMap.Count);
// If we connect to the service, there should be 1 connection
await service.Connect(connectParamsSame1);
- Assert.Equal(1, ownerToConnectionMap.Count);
+ Assert.AreEqual(1, ownerToConnectionMap.Count);
// If we connect again with the same URI, there should still be 1 connection
await service.Connect(connectParamsSame2);
- Assert.Equal(1, ownerToConnectionMap.Count);
+ Assert.AreEqual(1, ownerToConnectionMap.Count);
// If we connect with a different URI, there should be 2 connections
await service.Connect(connectParamsDifferent);
- Assert.Equal(2, ownerToConnectionMap.Count);
+ Assert.AreEqual(2, ownerToConnectionMap.Count);
// If we disconnect with the unique URI, there should be 1 connection
service.Disconnect(disconnectParamsDifferent);
- Assert.Equal(1, ownerToConnectionMap.Count);
+ Assert.AreEqual(1, ownerToConnectionMap.Count);
// If we disconnect with the duplicate URI, there should be 0 connections
service.Disconnect(disconnectParamsSame);
- Assert.Equal(0, ownerToConnectionMap.Count);
+ Assert.AreEqual(0, ownerToConnectionMap.Count);
}
- [Fact]
- public async void DbConnectionDoesntLeakUponDisconnect()
+ [Test]
+ public async Task DbConnectionDoesntLeakUponDisconnect()
{
// If we connect with a single URI and 2 connection types
var connectParamsDefault = new ConnectParams()
@@ -1274,8 +1244,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// We should have one ConnectionInfo and 2 DbConnections
ConnectionInfo connectionInfo = service.OwnerToConnectionMap[connectParamsDefault.OwnerUri];
- Assert.Equal(2, connectionInfo.CountConnections);
- Assert.Equal(1, service.OwnerToConnectionMap.Count);
+ Assert.AreEqual(2, connectionInfo.CountConnections);
+ Assert.AreEqual(1, service.OwnerToConnectionMap.Count);
// If we record when the Default connecton calls Close()
bool defaultDisconnectCalled = false;
@@ -1305,12 +1275,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.True(queryDisconnectCalled);
// And the maps that hold connection data should be empty
- Assert.Equal(0, connectionInfo.CountConnections);
- Assert.Equal(0, service.OwnerToConnectionMap.Count);
+ Assert.AreEqual(0, connectionInfo.CountConnections);
+ Assert.AreEqual(0, service.OwnerToConnectionMap.Count);
}
- [Fact]
- public async void ClosingQueryConnectionShouldLeaveDefaultConnectionOpen()
+ [Test]
+ public async Task ClosingQueryConnectionShouldLeaveDefaultConnectionOpen()
{
// Setup the connect and disconnect params
var connectParamsDefault = new ConnectParams()
@@ -1338,52 +1308,48 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
ConnectionInfo connectionInfo = service.OwnerToConnectionMap[connectParamsDefault.OwnerUri];
// There should be 2 connections in the map
- Assert.Equal(2, connectionInfo.CountConnections);
+ Assert.AreEqual(2, connectionInfo.CountConnections);
// If I Disconnect only the Query connection, there should be 1 connection in the map
service.Disconnect(disconnectParamsQuery);
- Assert.Equal(1, connectionInfo.CountConnections);
+ Assert.AreEqual(1, connectionInfo.CountConnections);
// If I reconnect, there should be 2 again
await service.Connect(connectParamsQuery);
- Assert.Equal(2, connectionInfo.CountConnections);
+ Assert.AreEqual(2, connectionInfo.CountConnections);
}
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- public async Task GetOrOpenNullOwnerUri(string ownerUri)
+ [Test]
+ public async Task GetOrOpenNullOwnerUri([Values(null, "")]string ownerUri)
{
// If: I have a connection service and I ask for a connection with an invalid ownerUri
// Then: An exception should be thrown
var service = TestObjects.GetTestConnectionService();
- await Assert.ThrowsAsync(
+ Assert.ThrowsAsync(
() => service.GetOrOpenConnection(ownerUri, ConnectionType.Default));
}
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- public async Task GetOrOpenNullConnectionType(string connType)
+ [Test]
+ public async Task GetOrOpenNullConnectionType([Values(null, "")] string connType)
{
// If: I have a connection service and I ask for a connection with an invalid connectionType
// Then: An exception should be thrown
var service = TestObjects.GetTestConnectionService();
- await Assert.ThrowsAsync(
+ Assert.ThrowsAsync(
() => service.GetOrOpenConnection(TestObjects.ScriptUri, connType));
}
- [Fact]
+ [Test]
public async Task GetOrOpenNoConnection()
{
// If: I have a connection service and I ask for a connection for an unconnected uri
// Then: An exception should be thrown
var service = TestObjects.GetTestConnectionService();
- await Assert.ThrowsAsync(
+ Assert.ThrowsAsync(
() => service.GetOrOpenConnection(TestObjects.ScriptUri, ConnectionType.Query));
}
- [Fact]
+ [Test]
public async Task GetOrOpenNoDefaultConnection()
{
// Setup: Create a connection service with an empty connection info obj
@@ -1393,11 +1359,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// If: I ask for a connection on a connection that doesn't have a default connection
// Then: An exception should be thrown
- await Assert.ThrowsAsync(
+ Assert.ThrowsAsync(
() => service.GetOrOpenConnection(TestObjects.ScriptUri, ConnectionType.Query));
}
- [Fact]
+ [Test]
public async Task GetOrOpenAdminDefaultConnection()
{
// Setup: Create a connection service with an empty connection info obj
@@ -1407,11 +1373,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// If: I ask for a connection on a connection that doesn't have a default connection
// Then: An exception should be thrown
- await Assert.ThrowsAsync(
+ Assert.ThrowsAsync(
() => service.GetOrOpenConnection(TestObjects.ScriptUri, ConnectionType.Query));
}
- [Fact]
+ [Test]
public async Task ConnectionWithAdminConnectionEnsuresOnlyOneConnectionCreated()
{
// If I try to connect using a connection string, it overrides the server name and username for the connection
@@ -1429,33 +1395,33 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
DbConnection defaultConn = await service.GetOrOpenConnection(connectionParameters.OwnerUri, ConnectionType.Default);
ConnectionInfo connInfo = service.OwnerToConnectionMap[connectionParameters.OwnerUri];
Assert.NotNull(defaultConn);
- Assert.Equal(connInfo.AllConnections.Count, 1);
+ Assert.AreEqual(1, connInfo.AllConnections.Count);
// Verify that for the Query, no new connection is created
DbConnection queryConn = await service.GetOrOpenConnection(connectionParameters.OwnerUri, ConnectionType.Query);
connInfo = service.OwnerToConnectionMap[connectionParameters.OwnerUri];
Assert.NotNull(defaultConn);
- Assert.Equal(connInfo.AllConnections.Count, 1);
+ Assert.AreEqual(1, connInfo.AllConnections.Count);
// Verify that if the query connection was closed, it will be reopened on requesting the connection again
- Assert.Equal(ConnectionState.Open, queryConn.State);
+ Assert.AreEqual(ConnectionState.Open, queryConn.State);
queryConn.Close();
- Assert.Equal(ConnectionState.Closed, queryConn.State);
+ Assert.AreEqual(ConnectionState.Closed, queryConn.State);
queryConn = await service.GetOrOpenConnection(connectionParameters.OwnerUri, ConnectionType.Query);
- Assert.Equal(ConnectionState.Open, queryConn.State);
+ Assert.AreEqual(ConnectionState.Open, queryConn.State);
}
- [Fact]
+ [Test]
public async Task ConnectionWithConnectionStringSucceeds()
{
// If I connect using a connection string instead of the normal parameters, the connection succeeds
var connectionParameters = TestObjects.GetTestConnectionParams(true);
var connectionResult = await TestObjects.GetTestConnectionService().Connect(connectionParameters);
- Assert.NotEmpty(connectionResult.ConnectionId);
+ Assert.That(connectionResult.ConnectionId, Is.Not.Null.Or.Empty, "check that the connection was successful");
}
- [Fact]
+ [Test]
public async Task ConnectionWithBadConnectionStringFails()
{
// If I try to connect using an invalid connection string, the connection fails
@@ -1463,10 +1429,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
connectionParameters.Connection.ConnectionString = "thisisnotavalidconnectionstring";
var connectionResult = await TestObjects.GetTestConnectionService().Connect(connectionParameters);
- Assert.NotEmpty(connectionResult.ErrorMessage);
+ Assert.That(connectionResult.ErrorMessage, Is.Not.Empty);
}
- [Fact]
+ [Test]
public async Task ConnectionWithConnectionStringOverridesServerInfo()
{
// If I try to connect using a connection string, it overrides the server name and username for the connection
@@ -1480,11 +1446,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// Connect and verify that the connectionParameters object's server name and username have been overridden
var connectionResult = await TestObjects.GetTestConnectionService().Connect(connectionParameters);
- Assert.NotEqual(serverName, connectionResult.ConnectionSummary.ServerName);
- Assert.NotEqual(userName, connectionResult.ConnectionSummary.UserName);
+ Assert.That(connectionResult.ConnectionSummary.ServerName, Is.Not.EqualTo(serverName));
+ Assert.That(connectionResult.ConnectionSummary.UserName, Is.Not.EqualTo(userName));
}
- [Fact]
+ [Test]
public async Task OtherParametersOverrideConnectionString()
{
// If I try to connect using a connection string, and set parameters other than the server name, username, or password,
@@ -1497,10 +1463,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
// Connect and verify that the connection string's database name has been overridden
var connectionResult = await TestObjects.GetTestConnectionService().Connect(connectionParameters);
- Assert.Equal(databaseName, connectionResult.ConnectionSummary.DatabaseName);
+ Assert.AreEqual(databaseName, connectionResult.ConnectionSummary.DatabaseName);
}
- [Fact]
+ [Test]
public async Task CanChangeDatabase()
{
string ownerUri = "file://my/sample/file.sql";
@@ -1537,10 +1503,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
connectionService.ChangeConnectionDatabaseContext(ownerUri, otherDbName);
- Assert.Equal(otherDbName, connection.Database);
+ Assert.AreEqual(otherDbName, connection.Database);
}
- [Fact]
+ [Test]
public async Task CanChangeDatabaseAzure()
{
@@ -1591,10 +1557,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
connectionService.ChangeConnectionDatabaseContext(ownerUri, otherDbName, true);
- Assert.Equal(otherDbName, dbName);
+ Assert.AreEqual(otherDbName, dbName);
}
- [Fact]
+ [Test]
public async Task ReturnsFalseIfNotForced()
{
string ownerUri = "file://my/sample/file.sql";
@@ -1644,13 +1610,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
Assert.False(connectionService.ChangeConnectionDatabaseContext(ownerUri, otherDbName));
- Assert.Equal(defaultDbName, dbName);
+ Assert.AreEqual(defaultDbName, dbName);
}
///
/// Test ParseConnectionString
///
- [Fact]
+ [Test]
public void ParseConnectionStringTest()
{
// If we make a connection to a live database
@@ -1660,19 +1626,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
var details = service.ParseConnectionString(connectionString);
- Assert.Equal("tcp:{servername},1433", details.ServerName);
- Assert.Equal("{databasename}", details.DatabaseName);
- Assert.Equal("{your_username}", details.UserName);
- Assert.Equal("{your_password}", details.Password);
- Assert.Equal(false, details.PersistSecurityInfo);
- Assert.Equal(false, details.MultipleActiveResultSets);
- Assert.Equal(true, details.Encrypt);
- Assert.Equal(false, details.TrustServerCertificate);
- Assert.Equal(30, details.ConnectTimeout);
+ Assert.AreEqual("tcp:{servername},1433", details.ServerName);
+ Assert.AreEqual("{databasename}", details.DatabaseName);
+ Assert.AreEqual("{your_username}", details.UserName);
+ Assert.AreEqual("{your_password}", details.Password);
+ Assert.AreEqual(false, details.PersistSecurityInfo);
+ Assert.AreEqual(false, details.MultipleActiveResultSets);
+ Assert.AreEqual(true, details.Encrypt);
+ Assert.AreEqual(false, details.TrustServerCertificate);
+ Assert.AreEqual(30, details.ConnectTimeout);
}
- [Fact]
- public async void ConnectingWithAzureAccountUsesToken()
+ [Test]
+ public async Task ConnectingWithAzureAccountUsesToken()
{
// Set up mock connection factory
var mockFactory = new Mock();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/DatabaseLocksManagerTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/DatabaseLocksManagerTests.cs
index 75ef5cdc..ca096074 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/DatabaseLocksManagerTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/DatabaseLocksManagerTests.cs
@@ -6,16 +6,17 @@
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
+ [TestFixture]
public class DatabaseLocksManagerTests
{
private const string server1 = "server1";
private const string database1 = "database1";
- [Fact]
+ [Test]
public void GainFullAccessShouldDisconnectTheConnections()
{
var connectionLock = new Mock();
@@ -30,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
}
}
- [Fact]
+ [Test]
public void ReleaseAccessShouldConnectTheConnections()
{
var connectionLock = new Mock();
@@ -45,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
}
}
- //[Fact]
+ //[Test]
public void SecondProcessToGainAccessShouldWaitForTheFirstProcess()
{
var connectionLock = new Mock();
@@ -62,9 +63,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
secondTimeGettingAccessFails = true;
}
- Assert.Equal(secondTimeGettingAccessFails, true);
+ Assert.AreEqual(true, secondTimeGettingAccessFails);
databaseLocksManager.ReleaseAccess(server1, database1);
- Assert.Equal(databaseLocksManager.GainFullAccessToDatabase(server1, database1), true);
+ Assert.AreEqual(true, databaseLocksManager.GainFullAccessToDatabase(server1, database1));
databaseLocksManager.ReleaseAccess(server1, database1);
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ReliableConnectionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ReliableConnectionTests.cs
index b4262bbe..4513cf82 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ReliableConnectionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Connection/ReliableConnectionTests.cs
@@ -7,16 +7,17 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
{
+ [TestFixture]
///
/// Tests for ReliableConnection code
///
public class ReliableConnectionTests
{
- [Fact]
+ [Test]
public void ReliableSqlConnectionUsesAzureToken()
{
ConnectionDetails details = TestObjects.GetTestConnectionDetails();
@@ -30,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
var reliableConnection = new ReliableSqlConnection(connectionString, retryPolicy, retryPolicy, azureAccountToken);
// Then the connection's azureAccountToken gets set
- Assert.Equal(azureAccountToken, reliableConnection.GetUnderlyingConnection().AccessToken);
+ Assert.AreEqual(azureAccountToken, reliableConnection.GetUnderlyingConnection().AccessToken);
}
}
}
\ No newline at end of file
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/CredentialServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/CredentialServiceTests.cs
index faed726a..1182abcf 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/CredentialServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/CredentialServiceTests.cs
@@ -12,16 +12,17 @@ using Microsoft.SqlTools.Credentials.Contracts;
using Microsoft.SqlTools.Credentials.Linux;
using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
{
+ [TestFixture]
///
/// Credential Service tests that should pass on all platforms, regardless of backing store.
/// These tests run E2E, storing values in the native credential store for whichever platform
/// tests are being run on
///
- public class CredentialServiceTests : IDisposable
+ public class CredentialServiceTests
{
private static readonly StoreConfig Config = new StoreConfig
{
@@ -39,18 +40,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
// Test-owned credential store used to clean up before/after tests to ensure code works as expected
// even if previous runs stopped midway through
- private readonly ICredentialStore credStore;
- private readonly CredentialService service;
- ///
- /// Constructor called once for every test
- ///
- public CredentialServiceTests()
+ private ICredentialStore credStore;
+ private CredentialService service;
+
+ [SetUp]
+ public void SetupCredentialServiceTests()
{
credStore = CredentialService.GetStoreForOS(Config);
service = new CredentialService(credStore, Config);
DeleteDefaultCreds();
}
+ [TearDown]
public void Dispose()
{
DeleteDefaultCreds();
@@ -73,7 +74,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
#endif
}
- [Fact]
+ [Test]
public async Task SaveCredentialThrowsIfCredentialIdMissing()
{
string errorResponse = null;
@@ -81,10 +82,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
await service.HandleSaveCredentialRequest(new Credential(null), contextMock.Object);
TestUtils.VerifyErrorSent(contextMock);
- Assert.Contains("ArgumentException", errorResponse);
+ Assert.That(errorResponse, Does.Contain("ArgumentException"));
}
- [Fact]
+ [Test]
public async Task SaveCredentialThrowsIfPasswordMissing()
{
string errorResponse = null;
@@ -95,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
Assert.True(errorResponse.Contains("ArgumentException") || errorResponse.Contains("ArgumentNullException"));
}
- [Fact]
+ [Test]
public async Task SaveCredentialWorksForSingleCredential()
{
await TestUtils.RunAndVerify(
@@ -103,7 +104,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
verify: Assert.True);
}
- [Fact]
+ [Test]
public async Task SaveCredentialWorksForEmptyPassword()
{
await TestUtils.RunAndVerify(
@@ -111,7 +112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
verify: Assert.True);
}
- [Fact]
+ [Test]
public async Task SaveCredentialSupportsSavingCredentialMultipleTimes()
{
await TestUtils.RunAndVerify(
@@ -123,7 +124,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
verify: Assert.True);
}
- [Fact]
+ [Test]
public async Task ReadCredentialWorksForSingleCredential()
{
// Given we have saved the credential
@@ -137,11 +138,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
test: (requestContext) => service.HandleReadCredentialRequest(new Credential(CredentialId, null), requestContext),
verify: (actual =>
{
- Assert.Equal(Password1, actual.Password);
+ Assert.AreEqual(Password1, actual.Password);
}));
}
- [Fact]
+ [Test]
public async Task ReadCredentialWorksForMultipleCredentials()
{
@@ -159,17 +160,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
test: (requestContext) => service.HandleReadCredentialRequest(new Credential(CredentialId, null), requestContext),
verify: (actual =>
{
- Assert.Equal(Password1, actual.Password);
+ Assert.AreEqual(Password1, actual.Password);
}));
await TestUtils.RunAndVerify(
test: (requestContext) => service.HandleReadCredentialRequest(new Credential(OtherCredId, null), requestContext),
verify: (actual =>
{
- Assert.Equal(OtherPassword, actual.Password);
+ Assert.AreEqual(OtherPassword, actual.Password);
}));
}
- [Fact]
+ [Test]
public async Task ReadCredentialHandlesPasswordUpdate()
{
// Given we have saved twice with a different password
@@ -187,11 +188,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
test: (requestContext) => service.HandleReadCredentialRequest(new Credential(CredentialId), requestContext),
verify: (actual =>
{
- Assert.Equal(Password2, actual.Password);
+ Assert.AreEqual(Password2, actual.Password);
}));
}
- [Fact]
+ [Test]
public async Task ReadCredentialThrowsIfCredentialIsNull()
{
string errorResponse = null;
@@ -200,10 +201,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
// Verify throws on null, and this is sent as an error
await service.HandleReadCredentialRequest(null, contextMock.Object);
TestUtils.VerifyErrorSent(contextMock);
- Assert.Contains("ArgumentNullException", errorResponse);
+ Assert.That(errorResponse, Does.Contain("ArgumentNullException"));
}
- [Fact]
+ [Test]
public async Task ReadCredentialThrowsIfIdMissing()
{
string errorResponse = null;
@@ -212,10 +213,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
// Verify throws with no ID
await service.HandleReadCredentialRequest(new Credential(), contextMock.Object);
TestUtils.VerifyErrorSent(contextMock);
- Assert.Contains("ArgumentException", errorResponse);
+ Assert.That(errorResponse, Does.Contain("ArgumentException"));
}
- [Fact]
+ [Test]
public async Task ReadCredentialReturnsNullPasswordForMissingCredential()
{
// Given a credential whose password doesn't exist
@@ -228,12 +229,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
verify: (actual =>
{
Assert.NotNull(actual);
- Assert.Equal(credWithNoPassword, actual.CredentialId);
+ Assert.AreEqual(credWithNoPassword, actual.CredentialId);
Assert.Null(actual.Password);
}));
}
- [Fact]
+ [Test]
public async Task DeleteCredentialThrowsIfIdMissing()
{
object errorResponse = null;
@@ -245,7 +246,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials
Assert.True(((string)errorResponse).Contains("ArgumentException"));
}
- [Fact]
+ [Test]
public async Task DeleteCredentialReturnsTrueOnlyIfCredentialExisted()
{
// Save should be true
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Linux/LinuxInteropTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Linux/LinuxInteropTests.cs
index 0d43bb84..5076fc36 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Linux/LinuxInteropTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Linux/LinuxInteropTests.cs
@@ -6,13 +6,14 @@
using Microsoft.SqlTools.Credentials;
using Microsoft.SqlTools.Credentials.Linux;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
-
+using NUnit.Framework;
+
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Linux
{
+ [TestFixture]
public class LinuxInteropTests
{
- [Fact]
+ [Test]
public void GetEUidReturnsInt()
{
#if !WINDOWS_ONLY_BUILD
@@ -23,14 +24,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Linux
#endif
}
- [Fact]
+ [Test]
public void GetHomeDirectoryFromPwFindsHomeDir()
{
#if !WINDOWS_ONLY_BUILD
RunIfWrapper.RunIfLinux(() =>
{
string userDir = LinuxCredentialStore.GetHomeDirectoryFromPw();
- Assert.StartsWith("/", userDir);
+ Assert.That(userDir, Does.StartWith("/"), "GetHomeDirectoryFromPw");
});
#endif
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/CredentialSetTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/CredentialSetTests.cs
index 09781c4d..dd1a6c3c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/CredentialSetTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/CredentialSetTests.cs
@@ -6,13 +6,14 @@
using System;
using Microsoft.SqlTools.Credentials.Win32;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
{
+ [TestFixture]
public class CredentialSetTests
{
- [Fact]
+ [Test]
public void CredentialSetCreate()
{
RunIfWrapper.RunIfWindows(() =>
@@ -21,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void CredentialSetCreateWithTarget()
{
RunIfWrapper.RunIfWindows(() =>
@@ -30,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void CredentialSetShouldBeIDisposable()
{
RunIfWrapper.RunIfWindows(() =>
@@ -39,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void CredentialSetLoad()
{
RunIfWrapper.RunIfWindows(() =>
@@ -56,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
CredentialSet set = new CredentialSet();
set.Load();
Assert.NotNull(set);
- Assert.NotEmpty(set);
+ Assert.That(set, Is.Not.Empty);
credential.Delete();
@@ -64,19 +65,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void CredentialSetLoadShouldReturnSelf()
{
RunIfWrapper.RunIfWindows(() =>
{
CredentialSet set = new CredentialSet();
- Assert.IsType(set.Load());
+ Assert.That(set.Load(), Is.SameAs(set));
set.Dispose();
});
}
- [Fact]
+ [Test]
public void CredentialSetLoadWithTargetFilter()
{
RunIfWrapper.RunIfWindows(() =>
@@ -90,7 +91,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
credential.Save();
CredentialSet set = new CredentialSet("filtertarget");
- Assert.Equal(1, set.Load().Count);
+ Assert.AreEqual(1, set.Load().Count);
set.Dispose();
});
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/Win32CredentialTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/Win32CredentialTests.cs
index ee42f4ea..5a66b847 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/Win32CredentialTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Credentials/Win32/Win32CredentialTests.cs
@@ -6,13 +6,14 @@
using System;
using Microsoft.SqlTools.Credentials.Win32;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
{
+ [TestFixture]
public class Win32CredentialTests
{
- [Fact]
+ [Test]
public void Credential_Create_ShouldNotThrowNull()
{
RunIfWrapper.RunIfWindows(() =>
@@ -21,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Create_With_Username_ShouldNotThrowNull()
{
RunIfWrapper.RunIfWindows(() =>
@@ -30,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Create_With_Username_And_Password_ShouldNotThrowNull()
{
RunIfWrapper.RunIfWindows(() =>
@@ -39,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Create_With_Username_Password_Target_ShouldNotThrowNull()
{
RunIfWrapper.RunIfWindows(() =>
@@ -48,7 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_ShouldBe_IDisposable()
{
RunIfWrapper.RunIfWindows(() =>
@@ -57,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Dispose_ShouldNotThrowException()
{
RunIfWrapper.RunIfWindows(() =>
@@ -66,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_ShouldThrowObjectDisposedException()
{
RunIfWrapper.RunIfWindows(() =>
@@ -77,7 +78,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Save()
{
RunIfWrapper.RunIfWindows(() =>
@@ -88,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Delete()
{
RunIfWrapper.RunIfWindows(() =>
@@ -98,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Delete_NullTerminator()
{
RunIfWrapper.RunIfWindows(() =>
@@ -109,7 +110,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
});
}
- [Fact]
+ [Test]
public void Credential_Load()
{
RunIfWrapper.RunIfWindows(() =>
@@ -120,15 +121,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Credentials.Win32
Win32Credential credential = new Win32Credential { Target = "target", Type = CredentialType.Generic };
Assert.True(credential.Load());
- Assert.NotEmpty(credential.Username);
+ Assert.That(credential.Username, Is.Not.Empty);
Assert.NotNull(credential.Password);
- Assert.Equal("username", credential.Username);
- Assert.Equal("password", credential.Password);
- Assert.Equal("target", credential.Target);
+ Assert.AreEqual("username", credential.Username);
+ Assert.AreEqual("password", credential.Password);
+ Assert.AreEqual("target", credential.Target);
});
}
- [Fact]
+ [Test]
public void Credential_Exists_Target_ShouldNotBeNull()
{
RunIfWrapper.RunIfWindows(() =>
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DacFx/DacFxTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DacFx/DacFxTests.cs
index 816f19e0..e9409733 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DacFx/DacFxTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DacFx/DacFxTests.cs
@@ -5,13 +5,14 @@
using System;
using Microsoft.SqlTools.ServiceLayer.DacFx;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DacFx
{
+ [TestFixture]
public class DacFxTests
{
- [Fact]
+ [Test]
public void ExtractParseVersionShouldThrowExceptionGivenInvalidVersion()
{
string invalidVersion = "invalidVerison";
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/BackupTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/BackupTests.cs
index e0040aee..d9be6167 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/BackupTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/BackupTests.cs
@@ -7,7 +7,7 @@ using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
using Microsoft.SqlTools.ServiceLayer.TaskServices;
using Moq;
using System.Threading.Tasks;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
@@ -17,7 +17,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Create and run a backup task
///
///
- [Fact]
+ [Test]
public async Task VerifyRunningBackupTask()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -28,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.NotNull(sqlTask);
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
+ Assert.AreEqual(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
});
await taskToVerify;
@@ -39,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Generate script for backup task
///
///
- [Fact]
+ [Test]
public async Task VerifyScriptBackupTask()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -52,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.NotNull(sqlTask);
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
+ Assert.AreEqual(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
});
await taskToVerify;
@@ -63,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Create and run multiple backup tasks
///
///
- [Fact]
+ [Test]
public async Task VerifyRunningMultipleBackupTasks()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -78,12 +78,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
+ Assert.AreEqual(SqlTaskStatus.Succeeded, sqlTask.TaskStatus);
});
Task taskToVerify2 = sqlTask2.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Succeeded, sqlTask2.TaskStatus);
+ Assert.AreEqual(SqlTaskStatus.Succeeded, sqlTask2.TaskStatus);
});
await Task.WhenAll(taskToVerify, taskToVerify2);
@@ -94,7 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Cancel a backup task
///
///
- [Fact]
+ [Test]
public async Task VerifyCancelBackupTask()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -105,8 +105,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.NotNull(sqlTask);
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
- Assert.Equal(sqlTask.IsCancelRequested, true);
+ Assert.AreEqual(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
+ Assert.AreEqual(true, sqlTask.IsCancelRequested);
((BackupOperationStub)backupOperation).BackupSemaphore.Release();
manager.Reset();
});
@@ -120,7 +120,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Cancel multiple backup tasks
///
///
- [Fact]
+ [Test]
public async Task VerifyCancelMultipleBackupTasks()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -137,16 +137,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
- Assert.Equal(sqlTask.IsCancelRequested, true);
+ Assert.AreEqual(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
+ Assert.AreEqual(true, sqlTask.IsCancelRequested);
((BackupOperationStub)backupOperation).BackupSemaphore.Release();
manager.Reset();
});
Task taskToVerify2 = sqlTask2.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Canceled, sqlTask2.TaskStatus);
- Assert.Equal(sqlTask2.IsCancelRequested, true);
+ Assert.AreEqual(SqlTaskStatus.Canceled, sqlTask2.TaskStatus);
+ Assert.AreEqual(true, sqlTask2.IsCancelRequested);
((BackupOperationStub)backupOperation2).BackupSemaphore.Release();
manager.Reset();
});
@@ -161,7 +161,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// Create two backup tasks and cancel one task
///
///
- [Fact]
+ [Test]
public async Task VerifyCombinationRunAndCancelBackupTasks()
{
using (SqlTaskManager manager = new SqlTaskManager())
@@ -179,15 +179,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Task taskToVerify = sqlTask.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
- Assert.Equal(sqlTask.IsCancelRequested, true);
+ Assert.AreEqual(SqlTaskStatus.Canceled, sqlTask.TaskStatus);
+ Assert.AreEqual(true, sqlTask.IsCancelRequested);
((BackupOperationStub)backupOperation).BackupSemaphore.Release();
manager.Reset();
});
Task taskToVerify2 = sqlTask2.RunAsync().ContinueWith(Task =>
{
- Assert.Equal(SqlTaskStatus.Succeeded, sqlTask2.TaskStatus);
+ Assert.AreEqual(SqlTaskStatus.Succeeded, sqlTask2.TaskStatus);
});
manager.CancelTask(sqlTask.TaskId);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DatabaseFileInfoTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DatabaseFileInfoTests.cs
index cbdf9ca6..6f012457 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DatabaseFileInfoTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DatabaseFileInfoTests.cs
@@ -8,19 +8,19 @@ using System.Collections.Generic;
using System.Text;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
public class DatabaseFileInfoTests
{
- [Fact]
+ [Test]
public void DatabaseFileInfoConstructorShouldThrowExceptionGivenNull()
{
Assert.Throws(() => new DatabaseFileInfo(null));
}
- [Fact]
+ [Test]
public void DatabaseFileInfoShouldReturnNullGivenEmptyProperties()
{
LocalizedPropertyInfo[] properties = new LocalizedPropertyInfo[] { };
@@ -29,7 +29,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(string.IsNullOrEmpty(fileInfo.GetPropertyValueAsString(BackupSetInfo.BackupComponentPropertyName)));
}
- [Fact]
+ [Test]
public void DatabaseFileInfoShouldReturnValuesGivenValidProperties()
{
LocalizedPropertyInfo[] properties = new LocalizedPropertyInfo[] {
@@ -46,8 +46,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
};
var fileInfo = new DatabaseFileInfo(properties);
- Assert.Equal(fileInfo.Id, "id");
- Assert.Equal(fileInfo.GetPropertyValueAsString("name"), "1");
+ Assert.AreEqual("id", fileInfo.Id);
+ Assert.AreEqual("1", fileInfo.GetPropertyValueAsString("name"));
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DisasterRecoveryFileValidatorUnitTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DisasterRecoveryFileValidatorUnitTests.cs
index 6581a410..4fdcd427 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DisasterRecoveryFileValidatorUnitTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DisasterRecoveryFileValidatorUnitTests.cs
@@ -4,7 +4,7 @@
//
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
@@ -13,7 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
///
public class DisasterRecoveryFileValidatorUnitTests
{
- [Fact]
+ [Test]
public void ValidatorShouldReturnTrueForNullArgument()
{
string message;
@@ -21,14 +21,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result);
}
- [Fact]
+ [Test]
public void GetMachineNameForLocalServer()
{
string machineName = DisasterRecoveryFileValidator.GetMachineName(DisasterRecoveryFileValidator.LocalSqlServer);
Assert.True(System.Environment.MachineName == machineName);
}
- [Fact]
+ [Test]
public void GetMachineNameForNamedServer()
{
string testMachineName = "testmachine";
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/LocalizedPropertyInfoTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/LocalizedPropertyInfoTests.cs
index 3f8f2143..e3fb07b7 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/LocalizedPropertyInfoTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/LocalizedPropertyInfoTests.cs
@@ -5,29 +5,29 @@
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
public class LocalizedPropertyInfoTests
{
- [Fact]
+ [Test]
public void PropertyDisplayNameShouldReturnNameWhenNotSet()
{
LocalizedPropertyInfo propertyInfo = new LocalizedPropertyInfo();
propertyInfo.PropertyName = "name";
- Assert.Equal(propertyInfo.PropertyDisplayName, propertyInfo.PropertyName);
+ Assert.AreEqual(propertyInfo.PropertyDisplayName, propertyInfo.PropertyName);
}
- [Fact]
+ [Test]
public void PropertyValudDisplayNameShouldReturnValudWhenNotSet()
{
LocalizedPropertyInfo propertyInfo = new LocalizedPropertyInfo();
propertyInfo.PropertyName = "name";
propertyInfo.PropertyValue = "value";
- Assert.Equal(propertyInfo.PropertyValueDisplayName, propertyInfo.PropertyValue);
+ Assert.AreEqual(propertyInfo.PropertyValueDisplayName, propertyInfo.PropertyValue);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/RestoreOptionsHelperTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/RestoreOptionsHelperTests.cs
index 3c987844..8e228d84 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/RestoreOptionsHelperTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/RestoreOptionsHelperTests.cs
@@ -10,13 +10,13 @@ using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
public class RestoreOptionsHelperTests
{
- [Fact]
+ [Test]
public void VerifyOptionsCreatedSuccessfullyIsResponse()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
VerifyOptions(result, optionValues);
}
- [Fact]
+ [Test]
public void RelocateAllFilesShouldBeReadOnlyGivenNoDbFiles()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -40,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.RelocateDbFiles].IsReadOnly);
}
- [Fact]
+ [Test]
public void DataFileFolderShouldBeReadOnlyGivenRelocateAllFilesSetToFalse()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.LogFileFolder].IsReadOnly);
}
- [Fact]
+ [Test]
public void DataFileFolderShouldBeCurrentValueGivenRelocateAllFilesSetToTrue()
{
string dataFile = "data files";
@@ -70,12 +70,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.NotNull(result);
Assert.False(result[RestoreOptionsHelper.DataFileFolder].IsReadOnly);
Assert.False(result[RestoreOptionsHelper.LogFileFolder].IsReadOnly);
- Assert.Equal(result[RestoreOptionsHelper.DataFileFolder].CurrentValue, dataFile);
- Assert.Equal(result[RestoreOptionsHelper.LogFileFolder].CurrentValue, logFile);
+ Assert.AreEqual(result[RestoreOptionsHelper.DataFileFolder].CurrentValue, dataFile);
+ Assert.AreEqual(result[RestoreOptionsHelper.LogFileFolder].CurrentValue, logFile);
}
- [Fact]
+ [Test]
public void KeepReplicationShouldBeReadOnlyGivenRecoveryStateWithNoRecovery()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.KeepReplication].IsReadOnly);
}
- [Fact]
+ [Test]
public void StandbyFileShouldBeReadOnlyGivenRecoveryStateNotWithStandBy()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -99,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.StandbyFile].IsReadOnly);
}
- [Fact]
+ [Test]
public void BackupTailLogShouldBeReadOnlyTailLogBackupNotPossible()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -112,7 +112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.TailLogBackupFile].IsReadOnly);
}
- [Fact]
+ [Test]
public void TailLogWithNoRecoveryShouldBeReadOnlyTailLogBackupWithNoRecoveryNotPossible()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -124,7 +124,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.TailLogWithNoRecovery].IsReadOnly);
}
- [Fact]
+ [Test]
public void StandbyFileShouldNotBeReadOnlyGivenRecoveryStateWithStandBy()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -136,7 +136,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.False(result[RestoreOptionsHelper.StandbyFile].IsReadOnly);
}
- [Fact]
+ [Test]
public void CloseExistingConnectionsShouldNotBeReadOnlyGivenCanDropExistingConnectionsSetToTrue()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -148,7 +148,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.False(result[RestoreOptionsHelper.CloseExistingConnections].IsReadOnly);
}
- [Fact]
+ [Test]
public void CloseExistingConnectionsShouldBeReadOnlyGivenCanDropExistingConnectionsSetToFalse()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -160,7 +160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.CloseExistingConnections].IsReadOnly);
}
- [Fact]
+ [Test]
public void KeepReplicationShouldNotBeReadOnlyGivenRecoveryStateWithNoRecovery()
{
GeneralRequestDetails optionValues = CreateOptionsTestData();
@@ -172,7 +172,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
Assert.True(result[RestoreOptionsHelper.KeepReplication].IsReadOnly);
}
- [Fact]
+ [Test]
public void KeepReplicationShouldSetToDefaultValueGivenRecoveryStateWithNoRecovery()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -187,10 +187,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
bool actual = restoreDatabaseTaskDataObject.RestoreOptions.KeepReplication;
bool expected = (bool)options[RestoreOptionsHelper.KeepReplication].DefaultValue;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
- [Fact]
+ [Test]
public void KeepReplicationShouldSetToValueInRequestGivenRecoveryStateWithRecovery()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -204,11 +204,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
bool actual = restoreDatabaseTaskDataObject.RestoreOptions.KeepReplication;
bool expected = true;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
- [Fact]
+ [Test]
public void SourceDatabaseNameShouldSetToDefaultIfNotValid()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -224,10 +224,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
string actual = restoreDatabaseTaskDataObject.SourceDatabaseName;
string expected = defaultDbName;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
- [Fact]
+ [Test]
public void SourceDatabaseNameShouldStayTheSameIfValid()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -243,10 +243,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
string actual = restoreDatabaseTaskDataObject.SourceDatabaseName;
string expected = currentDbName;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
- [Fact]
+ [Test]
public void TargetDatabaseNameShouldBeWhatIsRequested()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -262,10 +262,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
string actual = restoreDatabaseTaskDataObject.TargetDatabaseName;
string expected = currentDbName;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
- [Fact]
+ [Test]
public void TargetDatabaseNameShouldBeWhatIsRequested2()
{
RestoreParams restoreParams = CreateOptionsTestData();
@@ -281,7 +281,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
string actual = restoreDatabaseTaskDataObject.TargetDatabaseName;
string expected = currentDbName;
- Assert.Equal(actual, expected);
+ Assert.AreEqual(actual, expected);
}
@@ -360,90 +360,90 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
private void VerifyOptions(Dictionary optionInResponse, GeneralRequestDetails optionValues)
{
RestorePlanDetailInfo planDetailInfo = optionInResponse[RestoreOptionsHelper.DataFileFolder];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.DataFileFolder);
- Assert.Equal(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.DataFileFolder));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("DefaultDataFileFolder"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.DataFileFolder);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.DataFileFolder));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("DefaultDataFileFolder"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.LogFileFolder];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.LogFileFolder);
- Assert.Equal(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.LogFileFolder));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("DefaultLogFileFolder"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.LogFileFolder);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.LogFileFolder));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("DefaultLogFileFolder"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.RelocateDbFiles];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.RelocateDbFiles);
- Assert.Equal(planDetailInfo.IsReadOnly, (optionValues.GetOptionValue>("DbFiles").Count == 0));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
- Assert.Equal(planDetailInfo.DefaultValue, false);
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.RelocateDbFiles);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, (optionValues.GetOptionValue>("DbFiles").Count == 0));
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.RelocateDbFiles));
+ Assert.AreEqual(false, planDetailInfo.DefaultValue);
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.ReplaceDatabase];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.ReplaceDatabase);
- Assert.Equal(planDetailInfo.IsReadOnly, false);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.ReplaceDatabase));
- Assert.Equal(planDetailInfo.DefaultValue, false);
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.ReplaceDatabase);
+ Assert.AreEqual(false, planDetailInfo.IsReadOnly);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.ReplaceDatabase));
+ Assert.AreEqual(false, planDetailInfo.DefaultValue);
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.KeepReplication];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.KeepReplication);
- Assert.Equal(planDetailInfo.IsReadOnly, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState) == DatabaseRecoveryState.WithNoRecovery);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.KeepReplication));
- Assert.Equal(planDetailInfo.DefaultValue, false);
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.KeepReplication);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState) == DatabaseRecoveryState.WithNoRecovery);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.KeepReplication));
+ Assert.AreEqual(false, planDetailInfo.DefaultValue);
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.SetRestrictedUser];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.SetRestrictedUser);
- Assert.Equal(planDetailInfo.IsReadOnly, false);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.SetRestrictedUser));
- Assert.Equal(planDetailInfo.DefaultValue, false);
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.SetRestrictedUser);
+ Assert.AreEqual(false, planDetailInfo.IsReadOnly);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.SetRestrictedUser));
+ Assert.AreEqual(false, planDetailInfo.DefaultValue);
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.RecoveryState];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.RecoveryState);
- Assert.Equal(planDetailInfo.IsReadOnly, false);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState).ToString());
- Assert.Equal(planDetailInfo.DefaultValue, DatabaseRecoveryState.WithRecovery.ToString());
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.RecoveryState);
+ Assert.AreEqual(false, planDetailInfo.IsReadOnly);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState).ToString());
+ Assert.AreEqual(planDetailInfo.DefaultValue, DatabaseRecoveryState.WithRecovery.ToString());
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.StandbyFile];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.StandbyFile);
- Assert.Equal(planDetailInfo.IsReadOnly, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState) != DatabaseRecoveryState.WithStandBy);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.StandbyFile));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("GetDefaultStandbyFile"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.StandbyFile);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, optionValues.GetOptionValue(RestoreOptionsHelper.RecoveryState) != DatabaseRecoveryState.WithStandBy);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.StandbyFile));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("GetDefaultStandbyFile"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.BackupTailLog];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.BackupTailLog);
- Assert.Equal(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupPossible"));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.BackupTailLog));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("IsTailLogBackupPossible"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.BackupTailLog);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupPossible"));
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.BackupTailLog));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("IsTailLogBackupPossible"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.TailLogBackupFile];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.TailLogBackupFile);
- Assert.Equal(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupPossible")
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.TailLogBackupFile);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupPossible")
| !optionValues.GetOptionValue(RestoreOptionsHelper.BackupTailLog));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue("TailLogBackupFile"));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("GetDefaultTailLogbackupFile"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue("TailLogBackupFile"));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("GetDefaultTailLogbackupFile"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.TailLogWithNoRecovery];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.TailLogWithNoRecovery);
- Assert.Equal(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupWithNoRecoveryPossible")
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.TailLogWithNoRecovery);
+ Assert.AreEqual(planDetailInfo.IsReadOnly, !optionValues.GetOptionValue("IsTailLogBackupWithNoRecoveryPossible")
| !optionValues.GetOptionValue(RestoreOptionsHelper.BackupTailLog));
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue("TailLogWithNoRecovery"));
- Assert.Equal(planDetailInfo.DefaultValue, optionValues.GetOptionValue("IsTailLogBackupWithNoRecoveryPossible"));
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue("TailLogWithNoRecovery"));
+ Assert.AreEqual(planDetailInfo.DefaultValue, optionValues.GetOptionValue("IsTailLogBackupWithNoRecoveryPossible"));
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
planDetailInfo = optionInResponse[RestoreOptionsHelper.CloseExistingConnections];
- Assert.Equal(planDetailInfo.Name, RestoreOptionsHelper.CloseExistingConnections);
- Assert.Equal(planDetailInfo.IsReadOnly, false);
- Assert.Equal(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.CloseExistingConnections));
- Assert.Equal(planDetailInfo.DefaultValue, false);
- Assert.Equal(planDetailInfo.IsVisiable, true);
+ Assert.AreEqual(planDetailInfo.Name, RestoreOptionsHelper.CloseExistingConnections);
+ Assert.AreEqual(false, planDetailInfo.IsReadOnly);
+ Assert.AreEqual(planDetailInfo.CurrentValue, optionValues.GetOptionValue(RestoreOptionsHelper.CloseExistingConnections));
+ Assert.AreEqual(false, planDetailInfo.DefaultValue);
+ Assert.AreEqual(true, planDetailInfo.IsVisiable);
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/CellUpdateTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/CellUpdateTests.cs
index 242801ec..6ae12f1f 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/CellUpdateTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/CellUpdateTests.cs
@@ -9,13 +9,13 @@ using System.Data.Common;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class CellUpdateTests
{
- [Fact]
+ [Test]
public void NullColumnTest()
{
// If: I attempt to create a CellUpdate with a null column
@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(null, string.Empty));
}
- [Fact]
+ [Test]
public void NullStringValueTest()
{
// If: I attempt to create a CellUpdate with a null string value
@@ -31,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(GetWrapper("ntext"), null));
}
- [Fact]
+ [Test]
public void NullStringAllowedTest()
{
// If: I attempt to create a CellUpdate to set it to NULL
@@ -41,13 +41,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then: The value should be a DBNull and the string value should be the same as what
// was given
- Assert.IsType(cu.Value);
- Assert.Equal(DBNull.Value, cu.Value);
- Assert.Equal(nullString, cu.ValueAsString);
- Assert.Equal(col, cu.Column);
+ Assert.That(cu.Value, Is.InstanceOf());
+ Assert.AreEqual(DBNull.Value, cu.Value);
+ Assert.AreEqual(nullString, cu.ValueAsString);
+ Assert.AreEqual(col, cu.Column);
}
- [Fact]
+ [Test]
public void NullStringNotAllowedTest()
{
// If: I attempt to create a cell update to set to null when its not allowed
@@ -55,7 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(GetWrapper("ntext", false), "NULL"));
}
- [Fact]
+ [Test]
public void NullTextStringTest()
{
// If: I attempt to create a CellUpdate with the text 'NULL' (with mixed case)
@@ -63,16 +63,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
CellUpdate cu = new CellUpdate(col, "'NULL'");
// Then: The value should be NULL
- Assert.IsType(cu.Value);
- Assert.Equal("NULL", cu.Value);
- Assert.Equal("'NULL'", cu.ValueAsString);
- Assert.Equal(col, cu.Column);
+ Assert.That(cu.Value, Is.InstanceOf());
+ Assert.AreEqual("NULL", cu.Value);
+ Assert.AreEqual("'NULL'", cu.ValueAsString);
+ Assert.AreEqual(col, cu.Column);
}
- [Theory]
- [InlineData("This is way too long")]
- [InlineData("TooLong")]
- public void StringTooLongTest(string value)
+ [Test]
+ public void StringTooLongTest([Values("This is way too long", "TooLong")]string value)
{
// If: I attempt to create a CellUpdate to set it to a large string
// Then: I should get an exception thrown
@@ -80,8 +78,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(col, value));
}
- [Theory]
- [MemberData(nameof(ByteArrayTestParams))]
+ [Test]
+ [TestCaseSource(nameof(ByteArrayTestParams))]
public void ByteArrayTest(string strValue, byte[] expectedValue, string expectedString)
{
// If: I attempt to create a CellUpdate for a binary column
@@ -89,10 +87,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
CellUpdate cu = new CellUpdate(col, strValue);
// Then: The value should be a binary and should match the expected data
- Assert.IsType(cu.Value);
- Assert.Equal(expectedValue, cu.Value);
- Assert.Equal(expectedString, cu.ValueAsString);
- Assert.Equal(col, cu.Column);
+ Assert.That(cu.Value, Is.InstanceOf());
+ Assert.AreEqual(expectedValue, cu.Value);
+ Assert.AreEqual(expectedString, cu.ValueAsString);
+ Assert.AreEqual(col, cu.Column);
}
public static IEnumerable ByteArrayTestParams
@@ -134,7 +132,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Fact]
+ [Test]
public void ByteArrayInvalidFormatTest()
{
// If: I attempt to create a CellUpdate for a binary column
@@ -143,8 +141,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(col, "this is totally invalid"));
}
- [Theory]
- [MemberData(nameof(BoolTestParams))]
+ [Test]
+ [TestCaseSource(nameof(BoolTestParams))]
public void BoolTest(string input, bool output, string outputString)
{
// If: I attempt to create a CellUpdate for a boolean column
@@ -152,13 +150,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
CellUpdate cu = new CellUpdate(col, input);
// Then: The value should match what was expected
- Assert.IsType(cu.Value);
- Assert.Equal(output, cu.Value);
- Assert.Equal(outputString, cu.ValueAsString);
- Assert.Equal(col, cu.Column);
+ Assert.That(cu.Value, Is.InstanceOf());
+ Assert.AreEqual(output, cu.Value);
+ Assert.AreEqual(outputString, cu.ValueAsString);
+ Assert.AreEqual(col, cu.Column);
}
- public static IEnumerable BoolTestParams
+ private static IEnumerable BoolTestParams
{
get
{
@@ -169,7 +167,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Fact]
+ [Test]
public void BoolInvalidFormatTest()
{
// If: I create a CellUpdate for a bool column and provide an invalid numeric value
@@ -178,10 +176,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(col, "12345"));
}
- [Theory]
- [InlineData("24:00:00")]
- [InlineData("105:00:00")]
- public void TimeSpanTooLargeTest(string value)
+ [Test]
+ public void TimeSpanTooLargeTest([Values("24:00:00", "105:00:00")] string value)
{
// If: I create a cell update for a timespan column and provide a value that is over 24hrs
// Then: It should throw an exception
@@ -189,21 +185,33 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new CellUpdate(col, value));
}
- [Theory]
- [MemberData(nameof(RoundTripTestParams))]
- public void RoundTripTest(DbColumnWrapper col, object obj)
+ ///
+ /// Not using TestCaseSource because nUnit's test name generator
+ /// doesn't like DbColumnWrapper objects as a source, due
+ /// to that class lacking a ToString override.
+ ///
+ ///
+ ///
+ [Test]
+ public void RoundTripTest()
{
- // Setup: Figure out the test string
- string testString = obj.ToString();
-
- // If: I attempt to create a CellUpdate
- CellUpdate cu = new CellUpdate(col, testString);
-
- // Then: The value and type should match what we put in
- Assert.IsType(col.DataType, cu.Value);
- Assert.Equal(obj, cu.Value);
- Assert.Equal(testString, cu.ValueAsString);
- Assert.Equal(col, cu.Column);
+ foreach (var inputs in RoundTripTestParams)
+ {
+
+ var col = (DbColumnWrapper)inputs[0];
+ var obj = inputs[1];
+ // Setup: Figure out the test string
+ string testString = obj.ToString();
+
+ // If: I attempt to create a CellUpdate
+ CellUpdate cu = new CellUpdate(col, testString);
+
+ // Then: The value and type should match what we put in
+ Assert.That(cu.Value, Is.InstanceOf(col.DataType));
+ Assert.AreEqual(obj, cu.Value);
+ Assert.AreEqual(testString, cu.ValueAsString);
+ Assert.AreEqual(col, cu.Column);
+ }
}
public static IEnumerable RoundTripTestParams
@@ -228,10 +236,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public void AsDbCellValue(bool isNull)
+ [Test]
+ public void AsDbCellValue([Values]bool isNull)
{
// Setup: Create a cell update
var value = isNull ? "NULL" : "foo";
@@ -246,19 +252,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(dbc);
// ... The display value should be the same as the value we supplied
- Assert.Equal(value, dbc.DisplayValue);
+ Assert.AreEqual(value, dbc.DisplayValue);
// ... The null-ness of the value should be the same as what we supplied
- Assert.Equal(isNull, dbc.IsNull);
+ Assert.AreEqual(isNull, dbc.IsNull);
// ... We don't care *too* much about the raw value, but we'll check it anyhow
- Assert.Equal(isNull ? (object)DBNull.Value : value, dbc.RawObject);
+ Assert.AreEqual(isNull ? (object)DBNull.Value : value, dbc.RawObject);
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public void AsEditCellValue(bool isNull)
+ [Test]
+ public void AsEditCellValue([Values]bool isNull)
{
// Setup: Create a cell update
var value = isNull ? "NULL" : "foo";
@@ -273,13 +277,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(ec);
// ... The display value should be the same as the value we supplied
- Assert.Equal(value, ec.DisplayValue);
+ Assert.AreEqual(value, ec.DisplayValue);
// ... The null-ness of the value should be the same as what we supplied
- Assert.Equal(isNull, ec.IsNull);
+ Assert.AreEqual(isNull, ec.IsNull);
// ... We don't care *too* much about the raw value, but we'll check it anyhow
- Assert.Equal(isNull ? (object)DBNull.Value : value, ec.RawObject);
+ Assert.AreEqual(isNull ? (object)DBNull.Value : value, ec.RawObject);
// ... The edit cell should be dirty
Assert.True(ec.IsDirty);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/EditCellTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/EditCellTests.cs
index 85fcb452..568afbdb 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/EditCellTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/EditCellTests.cs
@@ -6,13 +6,13 @@
using System;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class EditCellTests
{
- [Fact]
+ [Test]
public void ConstructNullDbCell()
{
// If: I construct an EditCell with a null DbCellValue
@@ -20,7 +20,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new EditCell(null, true));
}
- [Fact]
+ [Test]
public void ConstructValid()
{
// Setup: Create a DbCellValue to copy the values from
@@ -36,9 +36,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The values I provided in the DbCellValue should be present
- Assert.Equal(source.DisplayValue, ec.DisplayValue);
- Assert.Equal(source.IsNull, ec.IsNull);
- Assert.Equal(source.RawObject, ec.RawObject);
+ Assert.AreEqual(source.DisplayValue, ec.DisplayValue);
+ Assert.AreEqual(source.IsNull, ec.IsNull);
+ Assert.AreEqual(source.RawObject, ec.RawObject);
// ... The is dirty value I set should be present
Assert.True(ec.IsDirty);
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/FilterMetadataTest.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/FilterMetadataTest.cs
index 4d1610fd..56608ff1 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/FilterMetadataTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/FilterMetadataTest.cs
@@ -6,7 +6,7 @@
using Microsoft.SqlTools.ServiceLayer.EditData;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
@@ -19,7 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
///
public class FilterMetadataTest
{
- [Fact]
+ [Test]
public void BasicFilterTest()
{
EditColumnMetadata[] metas = CreateMetadataColumns(new string[] { "[col1]", "[col2]", "[col3]" });
@@ -29,7 +29,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
ValidateFilteredData(filteredData, cols);
}
- [Fact]
+ [Test]
public void ReorderedResultsTest()
{
EditColumnMetadata[] metas = CreateMetadataColumns(new string[] { "[col1]", "[col2]", "[col3]" });
@@ -39,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
ValidateFilteredData(filteredData, cols);
}
- [Fact]
+ [Test]
public void LessResultColumnsTest()
{
EditColumnMetadata[] metas = CreateMetadataColumns(new string[] { "[col1]", "[col2]", "[col3]", "[fillerCol1]", "[fillerCol2]" });
@@ -49,7 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
ValidateFilteredData(filteredData, cols);
}
- [Fact]
+ [Test]
public void EmptyDataTest()
{
EditColumnMetadata[] metas = new EditColumnMetadata[0];
@@ -81,13 +81,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
private void ValidateFilteredData(EditColumnMetadata[] filteredData, DbColumnWrapper[] cols)
{
- Assert.Equal(cols.Length, filteredData.Length);
+ Assert.AreEqual(cols.Length, filteredData.Length);
for (int i = 0; i < cols.Length; i++)
{
- Assert.Equal(cols[i].ColumnName, filteredData[i].EscapedName);
+ Assert.AreEqual(cols[i].ColumnName, filteredData[i].EscapedName);
if (cols[i].ColumnOrdinal.HasValue)
{
- Assert.Equal(cols[i].ColumnOrdinal, filteredData[i].Ordinal);
+ Assert.AreEqual(cols[i].ColumnOrdinal, filteredData[i].Ordinal);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowCreateTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowCreateTests.cs
index a9185a3c..56e94414 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowCreateTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowCreateTests.cs
@@ -15,13 +15,13 @@ using Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class RowCreateTests
{
- [Fact]
+ [Test]
public async Task RowCreateConstruction()
{
// Setup: Create the values to store
@@ -33,9 +33,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
RowCreate rc = new RowCreate(rowId, rs, data.TableMetadata);
// Then: The values I provided should be available
- Assert.Equal(rowId, rc.RowId);
- Assert.Equal(rs, rc.AssociatedResultSet);
- Assert.Equal(data.TableMetadata, rc.AssociatedObjectMetadata);
+ Assert.AreEqual(rowId, rc.RowId);
+ Assert.AreEqual(rs, rc.AssociatedResultSet);
+ Assert.AreEqual(data.TableMetadata, rc.AssociatedObjectMetadata);
}
#region GetScript Tests
@@ -58,8 +58,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Theory]
- [MemberData(nameof(GetScriptMissingCellsData))]
+ [Test]
+ [TestCaseSource(nameof(GetScriptMissingCellsData))]
public async Task GetScriptMissingCell(bool includeIdentity, int defaultCols, int nullableCols, int valuesToSkipSetting)
{
// Setup: Generate the parameters for the row create
@@ -108,8 +108,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Theory]
- [MemberData(nameof(GetScriptData))]
+ [Test]
+ [TestCaseSource(nameof(GetScriptData))]
public async Task GetScript(bool includeIdentity, int colsWithDefaultConstraints, int colsThatAllowNull, int valuesToSkipSetting, RegexExpectedOutput expectedOutput)
{
// Setup:
@@ -142,7 +142,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(m.Success);
// Table name matches
- Assert.Equal(Common.TableName, m.Groups[1].Value);
+ Assert.AreEqual(Common.TableName, m.Groups[1].Value);
}
else
{
@@ -152,24 +152,22 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(m.Success);
// Table name matches
- Assert.Equal(Common.TableName, m.Groups[1].Value);
+ Assert.AreEqual(Common.TableName, m.Groups[1].Value);
// In columns match
string cols = m.Groups[2].Value;
- Assert.Equal(expectedOutput.ExpectedInColumns, cols.Split(',').Length);
+ Assert.AreEqual(expectedOutput.ExpectedInColumns, cols.Split(',').Length);
// In values match
string vals = m.Groups[3].Value;
- Assert.Equal(expectedOutput.ExpectedInValues, vals.Split(',').Length);
+ Assert.AreEqual(expectedOutput.ExpectedInValues, vals.Split(',').Length);
}
}
#endregion
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public async Task ApplyChanges(bool includeIdentity)
+ [Test]
+ public async Task ApplyChanges([Values]bool includeIdentity)
{
// Setup:
// ... Generate the parameters for the row create
@@ -185,12 +183,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
await rc.ApplyChanges(newRowReader);
// Then: The result set should have an additional row in it
- Assert.Equal(2, rs.RowCount);
+ Assert.AreEqual(2, rs.RowCount);
}
#region GetCommand Tests
- [Fact]
+ [Test]
public async Task GetCommandNullConnection()
{
// Setup: Create a row create
@@ -219,8 +217,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Theory]
- [MemberData(nameof(GetCommandMissingCellsData))]
+ [Test]
+ [TestCaseSource(nameof(GetCommandMissingCellsData))]
public async Task GetCommandMissingCellNoDefault(bool includeIdentity, int defaultCols, int nullableCols,
int valuesToSkip)
{
@@ -274,8 +272,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Theory]
- [MemberData(nameof(GetCommandData))]
+ [Test]
+ [TestCaseSource(nameof(GetCommandData))]
public async Task GetCommand(bool includeIdentity, int defaultCols, int nullableCols, int valuesToSkip, RegexExpectedOutput expectedOutput)
{
// Setup:
@@ -298,7 +296,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(cmd);
// ... There should be parameters in it
- Assert.Equal(expectedOutput.ExpectedInValues, cmd.Parameters.Count);
+ Assert.AreEqual(expectedOutput.ExpectedInValues, cmd.Parameters.Count);
// ... The script should match the expected regex output
ValidateCommandAgainstRegex(cmd.CommandText, expectedOutput);
@@ -308,7 +306,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
// Break the query into parts
string[] splitSql = sql.Split(Environment.NewLine);
- Assert.Equal(3, splitSql.Length);
+ Assert.AreEqual(3, splitSql.Length);
// Check the declare statement first
Regex declareRegex = new Regex(@"^DECLARE @(.+) TABLE \((.+)\)$");
@@ -321,7 +319,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Correct number of columns in declared table
string[] declareCols = declareMatch.Groups[2].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedOutColumns, declareCols.Length);
+ Assert.AreEqual(expectedOutput.ExpectedOutColumns, declareCols.Length);
// Check the insert statement in the middle
if (expectedOutput.ExpectedInColumns == 0 || expectedOutput.ExpectedInValues == 0)
@@ -332,16 +330,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(insertMatch.Success);
// Table name matches
- Assert.Equal(Common.TableName, insertMatch.Groups[1].Value);
+ Assert.AreEqual(Common.TableName, insertMatch.Groups[1].Value);
- // Output columns match
string[] outCols = insertMatch.Groups[2].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedOutColumns, outCols.Length);
- Assert.All(outCols, col => Assert.StartsWith("inserted.", col));
-
- // Output table name matches
- Assert.StartsWith("Insert", insertMatch.Groups[3].Value);
- Assert.EndsWith("Output", insertMatch.Groups[3].Value);
+ Assert.AreEqual(expectedOutput.ExpectedOutColumns, outCols.Length);
+ Assert.That(outCols, Has.All.StartsWith("inserted."), "Output columns match");
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(insertMatch.Groups[3].Value, Does.StartWith("Insert"), "Output table name matches");
+ Assert.That(insertMatch.Groups[3].Value, Does.EndWith("Output"));
+ });
}
else
{
@@ -351,25 +350,31 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(insertMatch.Success);
// Table name matches
- Assert.Equal(Common.TableName, insertMatch.Groups[1].Value);
+ Assert.AreEqual(Common.TableName, insertMatch.Groups[1].Value);
- // Output columns match
+ //
string[] outCols = insertMatch.Groups[3].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedOutColumns, outCols.Length);
- Assert.All(outCols, col => Assert.StartsWith("inserted.", col));
+ Assert.Multiple(() =>
+ {
+ Assert.AreEqual(expectedOutput.ExpectedOutColumns, outCols.Length);
+ Assert.That(outCols, Has.All.StartsWith("inserted."), "Output columns match");
+ });
// In columns match
string[] inCols = insertMatch.Groups[2].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedInColumns, inCols.Length);
-
- // Output table name matches
- Assert.StartsWith("Insert", insertMatch.Groups[4].Value);
- Assert.EndsWith("Output", insertMatch.Groups[4].Value);
-
+ Assert.AreEqual(expectedOutput.ExpectedInColumns, inCols.Length);
+
+ // Output table name matches
+ Assert.Multiple(() =>
+ {
+ Assert.That(insertMatch.Groups[4].Value, Does.StartWith("Insert"));
+ Assert.That(insertMatch.Groups[4].Value, Does.EndWith("Output"));
+ });
+
// In values match
string[] inVals = insertMatch.Groups[5].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedInValues, inVals.Length);
- Assert.All(inVals, val => Assert.Matches(@"@.+\d+_\d+", val));
+ Assert.AreEqual(expectedOutput.ExpectedInValues, inVals.Length);
+ Assert.That(inVals, Has.All.Match(@"@.+\d+_\d+"));
}
// Check the select statement last
@@ -379,7 +384,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Correct number of columns in declared table
string[] selectCols = selectMatch.Groups[1].Value.Split(", ");
- Assert.Equal(expectedOutput.ExpectedOutColumns, selectCols.Length);
+ Assert.AreEqual(expectedOutput.ExpectedOutColumns, selectCols.Length);
// Declared table name matches
Assert.True(selectMatch.Groups[2].Value.StartsWith("Insert"));
@@ -390,7 +395,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region GetEditRow Tests
- [Fact]
+ [Test]
public async Task GetEditRowNoAdditions()
{
// Setup: Generate a standard row create
@@ -405,19 +410,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The row should not be clean
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, er.State);
// ... The row should have a bunch of empty cells (equal to number of columns) and all are dirty
- Assert.Equal(rc.newCells.Length, er.Cells.Length);
- Assert.All(er.Cells, ec =>
- {
- Assert.Equal(string.Empty, ec.DisplayValue);
- Assert.False(ec.IsNull);
- Assert.True(ec.IsDirty);
- });
+ Assert.AreEqual(rc.newCells.Length, er.Cells.Length);
+ Assert.That(er.Cells.Select(c => c.DisplayValue), Has.All.Empty);
+ Assert.That(er.Cells.Select(ec => ec.IsDirty), Has.All.True);
}
- [Fact]
+ [Test]
public async Task GetEditRowWithDefaultValue()
{
// Setup: Generate a row create with default values
@@ -435,19 +436,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The row should not be clean
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, er.State);
// ... The row sould have a bunch of default values (equal to number of columns) and all are dirty
- Assert.Equal(rc.newCells.Length, er.Cells.Length);
- Assert.All(er.Cells, ec =>
- {
- Assert.Equal(Common.DefaultValue, ec.DisplayValue);
- Assert.False(ec.IsNull); // TODO: Update when we support null default values better
- Assert.True(ec.IsDirty);
- });
+ Assert.AreEqual(rc.newCells.Length, er.Cells.Length);
+ Assert.That(er.Cells.Select(ec => ec.DisplayValue), Has.All.EqualTo(Common.DefaultValue));
+ Assert.That(er.Cells.Select(ec => ec.IsDirty), Has.All.True);
}
- [Fact]
+ [Test]
public async Task GetEditRowWithCalculatedValue()
{
// Setup: Generate a row create with an identity column
@@ -462,28 +459,23 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The row should not be null
Assert.NotNull(er);
- Assert.Equal(er.Id, rowId);
+ Assert.AreEqual(er.Id, rowId);
// ... The row should not be clean
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, er.State);
// ... The row should have a TBD for the identity column
- Assert.Equal(rc.newCells.Length, er.Cells.Length);
- Assert.Equal(SR.EditDataComputedColumnPlaceholder, er.Cells[0].DisplayValue);
+ Assert.AreEqual(rc.newCells.Length, er.Cells.Length);
+ Assert.AreEqual(SR.EditDataComputedColumnPlaceholder, er.Cells[0].DisplayValue);
Assert.False(er.Cells[0].IsNull);
- Assert.True(er.Cells[0].IsDirty);
-
- // ... The rest of the cells should have empty display values
- Assert.All(er.Cells.Skip(1), ec =>
- {
- Assert.Equal(string.Empty, ec.DisplayValue);
- Assert.False(ec.IsNull);
- Assert.True(ec.IsDirty);
- });
+ Assert.True(er.Cells[0].IsDirty);
+
+ // ... The rest of the cells should have empty display values
+ Assert.That(er.Cells.Skip(1).Select(ec => new { ec.DisplayValue, ec.IsNull, ec.IsDirty }), Has.All.EqualTo(new { DisplayValue = string.Empty, IsNull = false, IsDirty = true }));
}
- [Fact]
+ [Test]
public async Task GetEditRowWithAdditions()
{
// Setp: Generate a row create with a cell added to it
@@ -497,14 +489,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The row should not be null and contain the same number of cells as columns
Assert.NotNull(er);
- Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, er.State);
// ... The row should not be clean
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, er.State);
// ... The row should have a single non-empty cell at the beginning that is dirty
- Assert.Equal(setValue, er.Cells[0].DisplayValue);
+ Assert.AreEqual(setValue, er.Cells[0].DisplayValue);
Assert.False(er.Cells[0].IsNull);
Assert.True(er.Cells[0].IsDirty);
@@ -512,7 +504,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
for (int i = 1; i < er.Cells.Length; i++)
{
EditCell ec = er.Cells[i];
- Assert.Equal(string.Empty, ec.DisplayValue);
+ Assert.AreEqual(string.Empty, ec.DisplayValue);
Assert.False(ec.IsNull);
Assert.True(ec.IsDirty);
}
@@ -522,11 +514,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region SetCell Tests
- [Theory]
- [InlineData(-1)] // Negative
- [InlineData(3)] // At edge of acceptable values
- [InlineData(100)] // Way too large value
- public async Task SetCellOutOfRange(int columnId)
+ [Test]
+ public async Task SetCellOutOfRange([Values(-1, 3, 100)]int columnId)
{
// Setup: Generate a row create
RowCreate rc = await GetStandardRowCreate();
@@ -535,7 +524,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => rc.SetCell(columnId, string.Empty));
}
- [Fact]
+ [Test]
public async Task SetCellNoChange()
{
// Setup: Generate a row create
@@ -549,7 +538,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The returned value should be equal to what we provided
Assert.NotNull(eucr);
Assert.NotNull(eucr.Cell);
- Assert.Equal(updateValue, eucr.Cell.DisplayValue);
+ Assert.AreEqual(updateValue, eucr.Cell.DisplayValue);
Assert.False(eucr.Cell.IsNull);
// ... The returned value should be dirty
@@ -562,7 +551,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(rc.newCells[0]);
}
- [Fact]
+ [Test]
public async Task SetCellHasCorrections()
{
// Setup:
@@ -591,7 +580,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The returned value should be equal to what we provided
Assert.NotNull(eucr);
Assert.NotNull(eucr.Cell);
- Assert.NotEqual("1000", eucr.Cell.DisplayValue);
+ Assert.That(eucr.Cell.DisplayValue, Is.Not.EqualTo("1000"));
Assert.False(eucr.Cell.IsNull);
// ... The returned value should be dirty
@@ -604,7 +593,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(rc.newCells[0]);
}
- [Fact]
+ [Test]
public async Task SetCellNull()
{
// Setup: Generate a row create
@@ -620,7 +609,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The returned value should be equal to what we provided
Assert.NotNull(eucr);
Assert.NotNull(eucr.Cell);
- Assert.Equal(nullValue, eucr.Cell.DisplayValue);
+ Assert.AreEqual(nullValue, eucr.Cell.DisplayValue);
Assert.True(eucr.Cell.IsNull);
// ... The returned value should be dirty
@@ -637,11 +626,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region RevertCell Tests
- [Theory]
- [InlineData(-1)] // Negative
- [InlineData(3)] // At edge of acceptable values
- [InlineData(100)] // Way too large value
- public async Task RevertCellOutOfRange(int columnId)
+ [Test]
+ public async Task RevertCellOutOfRange([Values(-1,3,100)]int columnId)
{
// Setup: Generate the row create
RowCreate rc = await GetStandardRowCreate();
@@ -651,10 +637,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => rc.RevertCell(columnId));
}
- [Theory]
- [InlineData(1)]
- [InlineData(0)]
- public async Task RevertCellNotSet(int defaultCols)
+ [Test]
+ public async Task RevertCellNotSet([Values(0,1)]int defaultCols)
{
// Setup:
// ... Generate the parameters for the row create
@@ -672,7 +656,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... We should get back an edit cell with a value based on the default value
string expectedDisplayValue = defaultCols > 0 ? Common.DefaultValue : string.Empty;
Assert.NotNull(result.Cell);
- Assert.Equal(expectedDisplayValue, result.Cell.DisplayValue);
+ Assert.AreEqual(expectedDisplayValue, result.Cell.DisplayValue);
Assert.False(result.Cell.IsNull); // TODO: Modify to support null defaults
// ... The row should be dirty
@@ -682,10 +666,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Null(rc.newCells[0]);
}
- [Theory]
- [InlineData(1)]
- [InlineData(0)]
- public async Task RevertCellThatWasSet(int defaultCols)
+ [Test]
+ public async Task RevertCellThatWasSet([Values(0, 1)] int defaultCols)
{
// Setup:
// ... Generate the parameters for the row create
@@ -704,7 +686,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... We should get back an edit cell with a value based on the default value
string expectedDisplayValue = defaultCols > 0 ? Common.DefaultValue : string.Empty;
Assert.NotNull(result.Cell);
- Assert.Equal(expectedDisplayValue, result.Cell.DisplayValue);
+ Assert.AreEqual(expectedDisplayValue, result.Cell.DisplayValue);
Assert.False(result.Cell.IsNull); // TODO: Modify to support null defaults
// ... The row should be dirty
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowDeleteTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowDeleteTests.cs
index a775072e..8784e9e4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowDeleteTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowDeleteTests.cs
@@ -13,13 +13,13 @@ using Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class RowDeleteTests
{
- [Fact]
+ [Test]
public async Task RowDeleteConstruction()
{
// Setup: Create the values to store
@@ -30,15 +30,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
RowDelete rc = new RowDelete(100, rs, data.TableMetadata);
// Then: The values I provided should be available
- Assert.Equal(100, rc.RowId);
- Assert.Equal(rs, rc.AssociatedResultSet);
- Assert.Equal(data.TableMetadata, rc.AssociatedObjectMetadata);
+ Assert.AreEqual(100, rc.RowId);
+ Assert.AreEqual(rs, rc.AssociatedResultSet);
+ Assert.AreEqual(data.TableMetadata, rc.AssociatedObjectMetadata);
}
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public async Task GetScriptTest(bool isMemoryOptimized)
+ [Test]
+ public async Task GetScriptTest([Values]bool isMemoryOptimized)
{
Common.TestDbColumnsWithTableMetadata data = new Common.TestDbColumnsWithTableMetadata(isMemoryOptimized, true, 0, 0);
ResultSet rs = await Common.GetResultSet(data.DbColumns, true);
@@ -51,16 +49,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The script should not be null
Assert.NotNull(script);
- // ... It should be formatted as a delete script
+ // ...
string scriptStart = $"DELETE FROM {data.TableMetadata.EscapedMultipartName}";
if (isMemoryOptimized)
{
scriptStart += " WITH(SNAPSHOT)";
}
- Assert.StartsWith(scriptStart, script);
+ Assert.That(script, Does.StartWith(scriptStart), "It should be formatted as a delete script");
}
- [Fact]
+ [Test]
public async Task ApplyChanges()
{
// Setup: Generate the parameters for the row delete object
@@ -72,15 +70,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
await rd.ApplyChanges(null); // Reader not used, can be null
// Then : The result set should have one less row in it
- Assert.Equal(0, rs.RowCount);
+ Assert.AreEqual(0, rs.RowCount);
}
- [Theory]
- [InlineData(true, true)]
- [InlineData(false, true)]
- [InlineData(true, false)]
- [InlineData(false, false)]
- public async Task GetCommand(bool includeIdentity, bool isMemoryOptimized)
+ [Test]
+ public async Task GetCommand([Values]bool includeIdentity, [Values]bool isMemoryOptimized)
{
// Setup:
// ... Create a row delete
@@ -100,7 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... Only the keys should be used for parameters
int expectedKeys = includeIdentity ? 1 : 3;
- Assert.Equal(expectedKeys, cmd.Parameters.Count);
+ Assert.AreEqual(expectedKeys, cmd.Parameters.Count);
// ... It should be formatted into an delete script
string regexTest = isMemoryOptimized
@@ -112,17 +106,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... There should be a table
string tbl = m.Groups[1].Value;
- Assert.Equal(data.TableMetadata.EscapedMultipartName, tbl);
+ Assert.AreEqual(data.TableMetadata.EscapedMultipartName, tbl);
// ... There should be as many where components as there are keys
string[] whereComponents = m.Groups[2].Value.Split(new[] {"AND"}, StringSplitOptions.None);
- Assert.Equal(expectedKeys, whereComponents.Length);
+ Assert.AreEqual(expectedKeys, whereComponents.Length);
- // ... Each component should have be equal to a parameter
- Assert.All(whereComponents, c => Assert.True(Regex.IsMatch(c.Trim(), @"\(.+ = @.+\)")));
+ Assert.That(whereComponents.Select(c => c.Trim()), Has.All.Match(@"\(.+ = @.+\)"), "Each component should be equal to a parameter");
}
- [Fact]
+ [Test]
public async Task GetCommandNullConnection()
{
// Setup: Create a row delete
@@ -133,7 +126,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => rd.GetCommand(null));
}
- [Fact]
+ [Test]
public async Task GetEditRow()
{
// Setup: Create a row delete
@@ -148,26 +141,26 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The state should be dirty
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyDelete, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyDelete, er.State);
// ... The ID should be the same as the one provided
- Assert.Equal(0, er.Id);
+ Assert.AreEqual(0, er.Id);
// ... The row should match the cells that were given and should be dirty
- Assert.Equal(cells.Length, er.Cells.Length);
+ Assert.AreEqual(cells.Length, er.Cells.Length);
for (int i = 0; i < cells.Length; i++)
{
DbCellValue originalCell = cells[i];
EditCell outputCell = er.Cells[i];
- Assert.Equal(originalCell.DisplayValue, outputCell.DisplayValue);
- Assert.Equal(originalCell.IsNull, outputCell.IsNull);
+ Assert.AreEqual(originalCell.DisplayValue, outputCell.DisplayValue);
+ Assert.AreEqual(originalCell.IsNull, outputCell.IsNull);
Assert.True(outputCell.IsDirty);
// Note: No real need to check the RawObject property
}
}
- [Fact]
+ [Test]
public async Task GetEditNullRow()
{
// Setup: Create a row delete
@@ -178,7 +171,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => rd.GetEditRow(null));
}
- [Fact]
+ [Test]
public async Task SetCell()
{
// Setup: Create a row delete
@@ -189,7 +182,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => rd.SetCell(0, null));
}
- [Fact]
+ [Test]
public async Task RevertCell()
{
// Setup: Create a row delete
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowEditBaseTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowEditBaseTests.cs
index 2cafdee1..c9217b3c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowEditBaseTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowEditBaseTests.cs
@@ -17,13 +17,13 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class RowEditBaseTests
{
- [Fact]
+ [Test]
public void ConstructWithoutExtendedMetadata()
{
// Setup: Create a table metadata that has not been extended
@@ -34,11 +34,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new RowEditTester(null, etm));
}
- [Theory]
- [InlineData(-1)] // Negative index
- [InlineData(2)] // Equal to count of columns
- [InlineData(100)] // Index larger than number of columns
- public async Task ValidateUpdatableColumnOutOfRange(int columnId)
+ [Test]
+ public async Task ValidateUpdatableColumnOutOfRange([Values(-1,2,100)]int columnId)
{
// Setup: Create a result set
var rs = await GetResultSet(
@@ -55,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => tester.ValidateColumn(columnId));
}
- [Fact]
+ [Test]
public async Task ValidateUpdatableColumnNotUpdatable()
{
// Setup: Create a result set with an identity column
@@ -73,8 +70,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => tester.ValidateColumn(0));
}
- [Theory]
- [MemberData(nameof(GetWhereClauseIsNotNullData))]
+ [Test]
+ [TestCaseSource(nameof(GetWhereClauseIsNotNullData))]
public async Task GetWhereClauseSimple(DbColumn col, object val, string nullClause)
{
// Setup: Create a result set and metadata provider with a single column
@@ -124,7 +121,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Fact]
+ [Test]
public async Task GetWhereClauseMultipleKeyColumns()
{
// Setup: Create a result set and metadata provider with multiple key columns
@@ -136,7 +133,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
rt.ValidateWhereClauseMultipleKeys();
}
- [Fact]
+ [Test]
public async Task GetWhereClauseNoKeyColumns()
{
// Setup: Create a result set and metadata provider with no key columns
@@ -148,7 +145,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
rt.ValidateWhereClauseNoKeys();
}
- [Fact]
+ [Test]
public async Task SortingByTypeTest()
{
// Setup: Create a result set and metadata we can reuse
@@ -164,12 +161,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
};
rowEdits.Sort();
- // Then: Delete should be the last operation to execute
+ // Then:
// (we don't care about the order of the other two)
- Assert.IsType(rowEdits.Last());
+ Assert.That(rowEdits.Last(), Is.InstanceOf(), "Delete should be the last operation to execute");
}
- [Fact]
+ [Test]
public async Task SortingUpdatesByRowIdTest()
{
// Setup: Create a result set and metadata we can reuse
@@ -186,12 +183,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
rowEdits.Sort();
// Then: They should be in order by row ID ASCENDING
- Assert.Equal(1, rowEdits[0].RowId);
- Assert.Equal(2, rowEdits[1].RowId);
- Assert.Equal(3, rowEdits[2].RowId);
+ Assert.AreEqual(1, rowEdits[0].RowId);
+ Assert.AreEqual(2, rowEdits[1].RowId);
+ Assert.AreEqual(3, rowEdits[2].RowId);
}
- [Fact]
+ [Test]
public async Task SortingCreatesByRowIdTest()
{
// Setup: Create a result set and metadata we can reuse
@@ -208,12 +205,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
rowEdits.Sort();
// Then: They should be in order by row ID ASCENDING
- Assert.Equal(1, rowEdits[0].RowId);
- Assert.Equal(2, rowEdits[1].RowId);
- Assert.Equal(3, rowEdits[2].RowId);
+ Assert.AreEqual(1, rowEdits[0].RowId);
+ Assert.AreEqual(2, rowEdits[1].RowId);
+ Assert.AreEqual(3, rowEdits[2].RowId);
}
- [Fact]
+ [Test]
public async Task SortingDeletesByRowIdTest()
{
// Setup: Create a result set and metadata we can reuse
@@ -230,9 +227,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
rowEdits.Sort();
// Then: They should be in order by row ID DESCENDING
- Assert.Equal(3, rowEdits[0].RowId);
- Assert.Equal(2, rowEdits[1].RowId);
- Assert.Equal(1, rowEdits[2].RowId);
+ Assert.AreEqual(3, rowEdits[0].RowId);
+ Assert.AreEqual(2, rowEdits[1].RowId);
+ Assert.AreEqual(1, rowEdits[2].RowId);
}
private static async Task GetResultSet(DbColumn[] columns, object[] row)
@@ -262,18 +259,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... There should only be one component
- Assert.Equal(1, wc.ClauseComponents.Count);
+ Assert.AreEqual(1, wc.ClauseComponents.Count);
- // ... Parameterization should be empty
- Assert.Empty(wc.Parameters);
+ Assert.That(wc.Parameters, Is.Empty, "Parameterization should be empty");
// ... The component should contain the name of the column and be null
- Assert.Equal(
+ Assert.AreEqual(
$"({AssociatedObjectMetadata.Columns.First().EscapedName} {nullValue})",
wc.ClauseComponents[0]);
// ... The complete clause should contain a single WHERE
- Assert.Equal($"WHERE {wc.ClauseComponents[0]}", wc.CommandText);
+ Assert.AreEqual($"WHERE {wc.ClauseComponents[0]}", wc.CommandText);
}
public void ValidateWhereClauseMultipleKeys()
@@ -284,14 +280,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... There should two components
var keys = AssociatedObjectMetadata.KeyColumns.ToArray();
- Assert.Equal(keys.Length, wc.ClauseComponents.Count);
+ Assert.AreEqual(keys.Length, wc.ClauseComponents.Count);
- // ... Parameterization should be empty
- Assert.Empty(wc.Parameters);
+ Assert.That(wc.Parameters, Is.Empty, "Parameterization should be empty");
- // ... The components should contain the name of the column and the value
- Regex r = new Regex(@"\([0-9a-z]+ = .+\)");
- Assert.All(wc.ClauseComponents, s => Assert.True(r.IsMatch(s)));
+ Assert.That(wc.ClauseComponents, Has.All.Match(@"\([0-9a-z]+ = .+\)"), "The components should contain the name of the column and the value");
// ... The complete clause should contain multiple cause components joined
// with and
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowUpdateTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowUpdateTests.cs
index 09a6a8fc..530f9242 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowUpdateTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/RowUpdateTests.cs
@@ -15,13 +15,13 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
public class RowUpdateTests
{
- [Fact]
+ [Test]
public async Task RowUpdateConstruction()
{
// Setup: Create the values to store
@@ -33,18 +33,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
RowUpdate rc = new RowUpdate(rowId, rs, data.TableMetadata);
// Then: The values I provided should be available
- Assert.Equal(rowId, rc.RowId);
- Assert.Equal(rs, rc.AssociatedResultSet);
- Assert.Equal(data.TableMetadata, rc.AssociatedObjectMetadata);
+ Assert.AreEqual(rowId, rc.RowId);
+ Assert.AreEqual(rs, rc.AssociatedResultSet);
+ Assert.AreEqual(data.TableMetadata, rc.AssociatedObjectMetadata);
}
#region SetCell Tests
- [Theory]
- [InlineData(-1)] // Negative
- [InlineData(3)] // At edge of acceptable values
- [InlineData(100)] // Way too large value
- public async Task SetCellOutOfRange(int columnId)
+ [Test]
+ public async Task SetCellOutOfRange([Values(-1,3,100)]int columnId)
{
// Setup: Generate a row create
RowUpdate ru = await GetStandardRowUpdate();
@@ -53,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => ru.SetCell(columnId, string.Empty));
}
- [Fact]
+ [Test]
public async Task SetCellImplicitRevertTest()
{
// Setup: Create a fake table to update
@@ -74,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(eucr.Cell);
// ... The new value we provided should be returned
- Assert.Equal(rs.GetRow(0)[1].DisplayValue, eucr.Cell.DisplayValue);
+ Assert.AreEqual(rs.GetRow(0)[1].DisplayValue, eucr.Cell.DisplayValue);
Assert.False(eucr.Cell.IsNull);
// ... The cell should be clean
@@ -90,11 +87,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... It should have 2 updates
string updates = m.Groups[1].Value;
string[] updateSplit = updates.Split(',');
- Assert.Equal(2, updateSplit.Length);
- Assert.All(updateSplit, s => Assert.Equal(2, s.Split('=').Length));
+ Assert.AreEqual(2, updateSplit.Length);
+ Assert.That(updateSplit.Select(s => s.Split('=').Length), Has.All.EqualTo(2));
}
- [Fact]
+ [Test]
public async Task SetCellImplicitRowRevertTests()
{
// Setup: Create a fake column to update
@@ -115,7 +112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(eucr.Cell);
// ... The old value should be returned
- Assert.Equal(rs.GetRow(0)[1].DisplayValue, eucr.Cell.DisplayValue);
+ Assert.AreEqual(rs.GetRow(0)[1].DisplayValue, eucr.Cell.DisplayValue);
Assert.False(eucr.Cell.IsNull);
// ... The cell should be clean
@@ -127,7 +124,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// TODO: Make sure that the script and command things will return null
}
- [Fact]
+ [Test]
public void SetCellHasCorrections()
{
// Setup:
@@ -161,8 +158,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(eucr.Cell);
// ... The value we used won't be returned
- Assert.NotEmpty(eucr.Cell.DisplayValue);
- Assert.NotEqual("1000", eucr.Cell.DisplayValue);
+ Assert.That(eucr.Cell.DisplayValue, Is.Not.Empty);
+ Assert.That(eucr.Cell.DisplayValue, Is.Not.EqualTo("1000"));
Assert.False(eucr.Cell.IsNull);
// ... The cell should be dirty
@@ -172,11 +169,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(eucr.IsRowDirty);
// ... There should be a cell update in the cell list
- Assert.Contains(0, ru.cellUpdates.Keys);
+ Assert.That(ru.cellUpdates.Keys, Has.Member(0));
Assert.NotNull(ru.cellUpdates[0]);
}
- [Fact]
+ [Test]
public async Task SetCell()
{
// Setup: Create a row update
@@ -191,7 +188,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.NotNull(eucr.Cell);
// ... The new value we provided should be returned
- Assert.Equal("col1", eucr.Cell.DisplayValue);
+ Assert.AreEqual("col1", eucr.Cell.DisplayValue);
Assert.False(eucr.Cell.IsNull);
// ... The row is still dirty
@@ -201,16 +198,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(eucr.Cell.IsDirty);
// ... There should be a cell update in the cell list
- Assert.Contains(0, ru.cellUpdates.Keys);
+ Assert.That(ru.cellUpdates.Keys, Has.Member(0));
Assert.NotNull(ru.cellUpdates[0]);
}
#endregion
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public async Task GetScriptTest(bool isMemoryOptimized)
+ [Test]
+ public async Task GetScriptTest([Values]bool isMemoryOptimized)
{
// Setup: Create a fake table to update
var data = new Common.TestDbColumnsWithTableMetadata(isMemoryOptimized, true, 0, 0);
@@ -237,19 +232,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
string tbl = m.Groups[1].Value;
string updates = m.Groups[2].Value;
string[] updateSplit = updates.Split(',');
- Assert.Equal(data.TableMetadata.EscapedMultipartName, tbl);
- Assert.Equal(3, updateSplit.Length);
- Assert.All(updateSplit, s => Assert.Equal(2, s.Split('=').Length));
+ Assert.AreEqual(data.TableMetadata.EscapedMultipartName, tbl);
+ Assert.AreEqual(3, updateSplit.Length);
+ Assert.That(updateSplit.Select(s => s.Split('=').Length), Has.All.EqualTo(2));
}
#region GetCommand Tests
- [Theory]
- [InlineData(true, true)]
- [InlineData(true, false)]
- [InlineData(false, true)]
- [InlineData(false, false)]
- public async Task GetCommand(bool includeIdentity, bool isMemoryOptimized)
+ [Test]
+ public async Task GetCommand([Values] bool includeIdentity, [Values] bool isMemoryOptimized)
{
// Setup:
// ... Create a row update with cell updates
@@ -284,7 +275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Correct number of columns in declared table
string[] declareCols = declareMatch.Groups[2].Value.Split(", ");
- Assert.Equal(rs.Columns.Length, declareCols.Length);
+ Assert.AreEqual(rs.Columns.Length, declareCols.Length);
// Check the update statement in the middle
string regex = isMemoryOptimized
@@ -295,21 +286,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(updateMatch.Success);
// Table name matches
- Assert.Equal(Common.TableName, updateMatch.Groups[1].Value);
+ Assert.AreEqual(Common.TableName, updateMatch.Groups[1].Value);
// Output columns match
string[] outCols = updateMatch.Groups[3].Value.Split(", ");
- Assert.Equal(rs.Columns.Length, outCols.Length);
- Assert.All(outCols, col => Assert.StartsWith("inserted.", col));
+ Assert.AreEqual(rs.Columns.Length, outCols.Length);
+ Assert.That(outCols, Has.All.StartsWith("inserted."));
- // Set columns match
string[] setCols = updateMatch.Groups[2].Value.Split(", ");
- Assert.Equal(3, setCols.Length);
- Assert.All(setCols, s => Assert.Matches(@".+ = @Value\d+_\d+", s));
-
- // Output table name matches
- Assert.StartsWith("Update", updateMatch.Groups[4].Value);
- Assert.EndsWith("Output", updateMatch.Groups[4].Value);
+ Assert.AreEqual(3, setCols.Length);
+ Assert.That(setCols, Has.All.Match(@".+ = @Value\d+_\d+"), "Set columns match");
+
+ // Output table name matches
+ Assert.That(updateMatch.Groups[4].Value, Does.StartWith("Update"));
+ Assert.That(updateMatch.Groups[4].Value, Does.EndWith("Output"));
// Check the select statement last
Regex selectRegex = new Regex(@"^SELECT (.+) FROM @(.+)$");
@@ -318,19 +308,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Correct number of columns in select statement
string[] selectCols = selectMatch.Groups[1].Value.Split(", ");
- Assert.Equal(rs.Columns.Length, selectCols.Length);
+ Assert.AreEqual(rs.Columns.Length, selectCols.Length);
// Select table name matches
- Assert.StartsWith("Update", selectMatch.Groups[2].Value);
- Assert.EndsWith("Output", selectMatch.Groups[2].Value);
+ Assert.That(selectMatch.Groups[2].Value, Does.StartWith("Update"));
+ Assert.That(selectMatch.Groups[2].Value, Does.EndWith("Output"));
// ... There should be an appropriate number of parameters in it
// (1 or 3 keys, 3 value parameters)
int expectedKeys = includeIdentity ? 1 : 3;
- Assert.Equal(expectedKeys + 3, cmd.Parameters.Count);
+ Assert.AreEqual(expectedKeys + 3, cmd.Parameters.Count);
}
- [Fact]
+ [Test]
public async Task GetCommandNullConnection()
{
// Setup: Create a row update
@@ -345,7 +335,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region GetEditRow Tests
- [Fact]
+ [Test]
public async Task GetEditRow()
{
// Setup: Create a row update with a cell set
@@ -361,31 +351,31 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The state should be dirty
Assert.True(er.IsDirty);
- Assert.Equal(EditRow.EditRowState.DirtyUpdate, er.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyUpdate, er.State);
// ... The ID should be the same as the one provided
- Assert.Equal(0, er.Id);
+ Assert.AreEqual(0, er.Id);
// ... The row should match the cells that were given, except for the updated cell
- Assert.Equal(cells.Length, er.Cells.Length);
+ Assert.AreEqual(cells.Length, er.Cells.Length);
for (int i = 1; i < cells.Length; i++)
{
DbCellValue originalCell = cells[i];
DbCellValue outputCell = er.Cells[i];
- Assert.Equal(originalCell.DisplayValue, outputCell.DisplayValue);
- Assert.Equal(originalCell.IsNull, outputCell.IsNull);
+ Assert.AreEqual(originalCell.DisplayValue, outputCell.DisplayValue);
+ Assert.AreEqual(originalCell.IsNull, outputCell.IsNull);
// Note: No real need to check the RawObject property
}
// ... The updated cell should match what it was set to and be dirty
EditCell newCell = er.Cells[0];
- Assert.Equal("foo", newCell.DisplayValue);
+ Assert.AreEqual("foo", newCell.DisplayValue);
Assert.False(newCell.IsNull);
Assert.True(newCell.IsDirty);
}
- [Fact]
+ [Test]
public async Task GetEditNullRow()
{
// Setup: Create a row update
@@ -400,10 +390,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region ApplyChanges Tests
- [Theory]
- [InlineData(true)]
- [InlineData(false)]
- public async Task ApplyChanges(bool includeIdentity)
+ [Test]
+ public async Task ApplyChanges([Values] bool includeIdentity)
{
// Setup:
// ... Create a row update (no cell updates needed)
@@ -420,11 +408,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The result set should have the same number of rows as before
- Assert.Equal(1, rs.RowCount);
+ Assert.AreEqual(1, rs.RowCount);
Assert.True(oldBytesWritten < rs.totalBytesWritten);
}
- [Fact]
+ [Test]
public async Task ApplyChangesNullReader()
{
// Setup:
@@ -435,18 +423,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// If: I ask for the changes to be applied with a null db reader
// Then: I should get an exception
- await Assert.ThrowsAsync(() => ru.ApplyChanges(null));
+ Assert.ThrowsAsync(() => ru.ApplyChanges(null));
}
#endregion
#region RevertCell Tests
- [Theory]
- [InlineData(-1)] // Negative
- [InlineData(3)] // At edge of acceptable values
- [InlineData(100)] // Way too large value
- public async Task RevertCellOutOfRange(int columnId)
+ [Test]
+ public async Task RevertCellOutOfRange([Values(-1, 3, 100)] int columnId)
{
// Setup:
// ... Create a row update (no cell updates needed)
@@ -459,7 +444,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => ru.RevertCell(columnId));
}
- [Fact]
+ [Test]
public async Task RevertCellNotSet()
{
// Setup:
@@ -478,16 +463,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... We should get the original value back
// @TODO: Check for a default value when we support it
Assert.NotNull(result.Cell);
- Assert.Equal(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
+ Assert.AreEqual(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
// ... The row should be clean
Assert.False(result.IsRowDirty);
- // ... The cell should no longer be set
- Assert.DoesNotContain(0, ru.cellUpdates.Keys);
+ Assert.That(ru.cellUpdates.Keys, Has.None.Zero, "The cell should no longer be set");
}
- [Fact]
+ [Test]
public async Task RevertCellThatWasSet()
{
// Setup:
@@ -508,16 +492,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... We should get the original value back
// @TODO: Check for a default value when we support it
Assert.NotNull(result.Cell);
- Assert.Equal(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
+ Assert.AreEqual(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
// ... The row should be dirty still
Assert.True(result.IsRowDirty);
- // ... The cell should no longer be set
- Assert.DoesNotContain(0, ru.cellUpdates.Keys);
+ Assert.That(ru.cellUpdates.Keys, Has.None.Zero, "The cell should no longer be set");
}
- [Fact]
+ [Test]
public async Task RevertCellRevertsRow()
{
// Setup:
@@ -537,13 +520,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... We should get the original value back
// @TODO: Check for a default value when we support it
Assert.NotNull(result.Cell);
- Assert.Equal(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
+ Assert.AreEqual(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue);
// ... The row should now be reverted
Assert.False(result.IsRowDirty);
- // ... The cell should no longer be set
- Assert.DoesNotContain(0, ru.cellUpdates.Keys);
+ Assert.That(ru.cellUpdates.Keys, Has.None.Zero, "The cell should no longer be set");
}
#endregion
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/ServiceIntegrationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/ServiceIntegrationTests.cs
index f3472671..79423a58 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/ServiceIntegrationTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/ServiceIntegrationTests.cs
@@ -7,6 +7,7 @@ using System;
using System.Data.Common;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.SqlServer.Dac.Model;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.EditData;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
@@ -17,7 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
@@ -25,12 +26,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
#region EditSession Operation Helper Tests
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData(" \t\n\r")]
- [InlineData("Does not exist")]
- public async Task NullOrMissingSessionId(string sessionId)
+ [Test]
+ public async Task NullOrMissingSessionId([Values(null, "", " \t\n\r", "Does not exist")] string sessionId)
{
// Setup:
// ... Create a edit data service
@@ -48,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
efv.Validate();
}
- [Fact]
+ [Test]
public async Task OperationThrows()
{
// Setup:
@@ -74,12 +71,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region Dispose Tests
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData(" \t\n\r")]
- [InlineData("Does not exist")]
- public async Task DisposeNullOrMissingSessionId(string sessionId)
+ [Test]
+ public async Task DisposeNullOrMissingSessionId([Values(null, "", " \t\n\r", "Does not exist")] string sessionId)
{
// Setup: Create a edit data service
var eds = new EditDataService(null, null, null);
@@ -93,7 +86,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
efv.Validate();
}
- [Fact]
+ [Test]
public async Task DisposeSuccess()
{
// Setup: Create an edit data service with a session
@@ -110,13 +103,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... It should have completed successfully
efv.Validate();
- // ... And the session should have been removed from the active session list
- Assert.Empty(eds.ActiveSessions);
+ Assert.That(eds.ActiveSessions, Is.Empty, "And the session should have been removed from the active session list");
}
#endregion
- [Fact]
+ [Test]
public async Task DeleteSuccess()
{
// Setup: Create an edit data service with a session
@@ -138,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(s.EditCache.Any(e => e.Value is RowDelete));
}
- [Fact]
+ [Test]
public async Task CreateSucceeds()
{
// Setup: Create an edit data service with a session
@@ -160,7 +152,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(s.EditCache.Any(e => e.Value is RowCreate));
}
- [Fact]
+ [Test]
public async Task RevertCellSucceeds()
{
// Setup:
@@ -193,10 +185,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The edit cache should be empty again
EditSession s = eds.ActiveSessions[Constants.OwnerUri];
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
- [Fact]
+ [Test]
public async Task RevertRowSucceeds()
{
// Setup: Create an edit data service with a session that has an pending edit
@@ -217,10 +209,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The edit cache should be empty again
EditSession s = eds.ActiveSessions[Constants.OwnerUri];
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
- [Fact]
+ [Test]
public async Task UpdateSuccess()
{
// Setup: Create an edit data service with a session
@@ -254,7 +246,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
edit.Verify(e => e.SetCell(It.IsAny(), It.IsAny()), Times.Once);
}
- [Fact]
+ [Test]
public async Task GetRowsSuccess()
{
// Setup: Create an edit data service with a session
@@ -268,8 +260,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
.AddResultValidation(esr =>
{
Assert.NotNull(esr);
- Assert.NotEmpty(esr.Subset);
- Assert.NotEqual(0, esr.RowCount);
+ Assert.That(esr.Subset, Is.Not.Empty);
+ Assert.That(esr.RowCount, Is.Not.EqualTo(0));
})
.Complete();
await eds.HandleSubsetRequest(new EditSubsetParams
@@ -285,11 +277,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
#region Initialize Tests
- [Theory]
- [InlineData(null, "table", "table")] // Null owner URI
- [InlineData(Common.OwnerUri, null, "table")] // Null object name
- [InlineData(Common.OwnerUri, "table", null)] // Null object type
- public async Task InitializeNullParams(string ownerUri, string objName, string objType)
+ [Test]
+ [Sequential]
+ public async Task InitializeNullParams([Values(null, Common.OwnerUri, Common.OwnerUri)] string ownerUri,
+ [Values("table", null, "table")] string objName,
+ [Values("table", "table", null)] string objType)
{
// Setup: Create an edit data service without a session
var eds = new EditDataService(null, null, null);
@@ -314,10 +306,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
efv.Validate();
// ... There should not be a session
- Assert.Empty(eds.ActiveSessions);
+ Assert.That(eds.ActiveSessions, Is.Empty);
}
- [Fact]
+ [Test]
public async Task InitializeSessionExists()
{
// Setup: Create an edit data service with a session already defined
@@ -343,12 +335,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
efv.Validate();
// ... The original session should still be there
- Assert.Equal(1, eds.ActiveSessions.Count);
- Assert.Equal(session, eds.ActiveSessions[Constants.OwnerUri]);
+ Assert.AreEqual(1, eds.ActiveSessions.Count);
+ Assert.AreEqual(session, eds.ActiveSessions[Constants.OwnerUri]);
}
// Disable flaky test for investigation (karlb - 3/13/2018)
- //[Fact]
+ //[Test]
public async Task InitializeSessionSuccess()
{
// Setup:
@@ -391,7 +383,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
.AddEventValidation(EditSessionReadyEvent.Type, esrp =>
{
Assert.NotNull(esrp);
- Assert.Equal(Constants.OwnerUri, esrp.OwnerUri);
+ Assert.AreEqual(Constants.OwnerUri, esrp.OwnerUri);
Assert.True(esrp.Success);
Assert.Null(esrp.Message);
})
@@ -404,17 +396,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
efv.Validate();
// ... The session should have been created
- Assert.Equal(1, eds.ActiveSessions.Count);
+ Assert.AreEqual(1, eds.ActiveSessions.Count);
Assert.True(eds.ActiveSessions.Keys.Contains(Constants.OwnerUri));
- }
-
+ }
+
#endregion
-
- [Theory]
- [InlineData("table", "myschema", new [] { "myschema", "table" })] // Use schema
- [InlineData("table", null, new [] { "table" })] // skip schema
- [InlineData("schema.table", "myschema", new [] { "myschema", "schema.table"})] // Use schema
- [InlineData("schema.table", null, new [] { "schema", "table"})] // Split object name into schema
+ private static readonly object[] schemaNameParameters =
+ {
+ new object[] {"table", "myschema", new[] { "myschema", "table" } }, // Use schema
+ new object[] {"table", null, new[] { "table" } }, // skip schema
+ new object[] {"schema.table", "myschema", new[] { "myschema", "schema.table" } }, // Use schema
+ new object[] {"schema.table", null, new[] { "schema", "table" } }, // Split object name into schema
+ };
+
+ [Test, TestCaseSource(nameof(schemaNameParameters))]
public void ShouldUseSchemaNameIfDefined(string objName, string schemaName, string[] expectedNameParts)
{
// Setup: Create an edit data service without a session
@@ -434,7 +429,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
string[] nameParts = EditSession.GetEditTargetName(initParams);
// Then:
- Assert.Equal(expectedNameParts, nameParts);
+ Assert.AreEqual(expectedNameParts, nameParts);
}
private static async Task GetDefaultSession()
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/SessionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/SessionTests.cs
index d4a84a7a..be56714e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/SessionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/EditData/SessionTests.cs
@@ -20,7 +20,7 @@ using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
@@ -28,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
{
#region Construction Tests
- [Fact]
+ [Test]
public void SessionConstructionNullMetadataFactory()
{
// If: I create a session object with a null metadata factory
@@ -36,7 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => new EditSession(null));
}
- [Fact]
+ [Test]
public void SessionConstructionValid()
{
// If: I create a session object with a proper arguments
@@ -53,14 +53,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Null(s.CommitTask);
// ... The next row ID should be the default long
- Assert.Equal(default(long), s.NextRowId);
+ Assert.AreEqual(default(long), s.NextRowId);
}
#endregion
#region Validate Tests
- [Fact]
+ [Test]
public void SessionValidateUnfinishedQuery()
{
// If: I create a session object with a query that hasn't finished execution
@@ -70,7 +70,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => EditSession.ValidateQueryForSession(q));
}
- [Fact]
+ [Test]
public void SessionValidateIncorrectResultSet()
{
// Setup: Create a query that yields >1 result sets
@@ -94,7 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => EditSession.ValidateQueryForSession(query));
}
- [Fact]
+ [Test]
public void SessionValidateValidResultSet()
{
// If: I validate a query for a session with a valid query
@@ -109,7 +109,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region Create Row Tests
- [Fact]
+ [Test]
public void CreateRowNotInitialized()
{
// Setup:
@@ -122,7 +122,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.CreateRow());
}
- [Fact]
+ [Test]
public async Task CreateRowAddFailure()
{
// NOTE: This scenario should theoretically never occur, but is tested for completeness
@@ -143,13 +143,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.CreateRow());
// ... The mock edit should still exist
- Assert.Equal(mockEdit, s.EditCache[rs.RowCount]);
+ Assert.AreEqual(mockEdit, s.EditCache[rs.RowCount]);
// ... The next row ID should not have changes
- Assert.Equal(rs.RowCount, s.NextRowId);
+ Assert.AreEqual(rs.RowCount, s.NextRowId);
}
- [Fact]
+ [Test]
public async Task CreateRowSuccess()
{
// Setup: Create a session with a proper query and metadata
@@ -163,20 +163,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The new ID should be equal to the row count
- Assert.Equal(rs.RowCount, result.NewRowId);
+ Assert.AreEqual(rs.RowCount, result.NewRowId);
// ... The next row ID should have been incremented
- Assert.Equal(rs.RowCount + 1, s.NextRowId);
+ Assert.AreEqual(rs.RowCount + 1, s.NextRowId);
// ... There should be a new row create object in the cache
- Assert.Contains(result.NewRowId, s.EditCache.Keys);
- Assert.IsType(s.EditCache[result.NewRowId]);
+ Assert.That(s.EditCache.Keys, Has.Member(result.NewRowId));
+ Assert.That(s.EditCache[result.NewRowId], Is.InstanceOf());
// ... The default values should be returned (we will test this in depth below)
- Assert.NotEmpty(result.DefaultValues);
+ Assert.That(result.DefaultValues, Is.Not.Empty);
}
- [Fact]
+ [Test]
public async Task CreateRowDefaultTest()
{
// Setup:
@@ -229,18 +229,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(result.NewRowId > 0);
// ... There should be 3 default values (3 columns)
- Assert.NotEmpty(result.DefaultValues);
- Assert.Equal(3, result.DefaultValues.Length);
+ Assert.That(result.DefaultValues, Is.Not.Empty);
+ Assert.AreEqual(3, result.DefaultValues.Length);
// ... There should be specific values for each kind of default
Assert.Null(result.DefaultValues[0]);
- Assert.Equal("default", result.DefaultValues[1]);
+ Assert.AreEqual("default", result.DefaultValues[1]);
}
#endregion
- [Theory]
- [MemberData(nameof(RowIdOutOfRangeData))]
+ [Test]
+ [TestCaseSource(nameof(RowIdOutOfRangeData))]
public async Task RowIdOutOfRange(long rowId, Action testAction)
{
// Setup: Create a session with a proper query and metadata
@@ -285,7 +285,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region Initialize Tests
- [Fact]
+ [Test]
public void InitializeAlreadyInitialized()
{
// Setup:
@@ -298,7 +298,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.Initialize(null, null, null, null, null));
}
- [Fact]
+ [Test]
public void InitializeAlreadyInitializing()
{
// Setup:
@@ -311,8 +311,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.Initialize(null, null, null, null, null));
}
- [Theory]
- [MemberData(nameof(InitializeNullParamsData))]
+ [Test]
+ [TestCaseSource(nameof(InitializeNullParamsData))]
public void InitializeNullParams(EditInitializeParams initParams, EditSession.Connector c,
EditSession.QueryRunner qr, Func sh, Func fh)
{
@@ -321,9 +321,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Mock emf = new Mock();
EditSession s = new EditSession(emf.Object);
- // If: I initialize it with a missing parameter
- // Then: It should throw an exception
- Assert.ThrowsAny(() => s.Initialize(initParams, c, qr, sh, fh));
+ Assert.That(() => s.Initialize(initParams, c, qr, sh, fh), Throws.InstanceOf(), "I initialize it with a missing parameter. It should throw an exception");
}
public static IEnumerable InitializeNullParamsData
@@ -376,7 +374,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
}
- [Fact]
+ [Test]
public async Task InitializeMetadataFails()
{
// Setup:
@@ -407,7 +405,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
successHandler.Verify(f => f(), Times.Never);
}
- [Fact]
+ [Test]
public async Task InitializeQueryFailException()
{
// Setup:
@@ -444,10 +442,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
successHandler.Verify(f => f(), Times.Never);
}
- [Theory]
- [InlineData(null)]
- [InlineData("It fail.")]
- public async Task InitializeQueryFailReturnNull(string message)
+ [Test]
+ public async Task InitializeQueryFailReturnNull([Values(null, "It fail.")] string message)
{
// Setup:
// ... Create a metadata factory that will return some generic column information
@@ -484,7 +480,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
successHandler.Verify(f => f(), Times.Never);
}
- [Fact]
+ [Test]
public async Task InitializeSuccess()
{
// Setup:
@@ -521,16 +517,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... The session should have been initialized
Assert.True(s.IsInitialized);
- Assert.Equal(rs.RowCount, s.NextRowId);
+ Assert.AreEqual(rs.RowCount, s.NextRowId);
Assert.NotNull(s.EditCache);
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
#endregion
#region Delete Row Tests
- [Fact]
+ [Test]
public void DeleteRowNotInitialized()
{
// Setup:
@@ -543,7 +539,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.DeleteRow(0));
}
- [Fact]
+ [Test]
public async Task DeleteRowAddFailure()
{
// Setup:
@@ -560,10 +556,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.DeleteRow(0));
// ... The mock edit should still exist
- Assert.Equal(mockEdit, s.EditCache[0]);
+ Assert.AreEqual(mockEdit, s.EditCache[0]);
}
- [Fact]
+ [Test]
public async Task DeleteRowSuccess()
{
// Setup: Create a session with a proper query and metadata
@@ -572,16 +568,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// If: I add a row to the session
s.DeleteRow(0);
- // Then: There should be a new row delete object in the cache
- Assert.Contains(0, s.EditCache.Keys);
- Assert.IsType(s.EditCache[0]);
+ Assert.That(s.EditCache.Keys, Has.Member(0));
+ Assert.That(s.EditCache[0], Is.InstanceOf(), "There should be a new row delete object in the cache");
}
#endregion
#region Revert Row Tests
- [Fact]
+ [Test]
public void RevertRowNotInitialized()
{
// Setup:
@@ -594,7 +589,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.RevertRow(0));
}
- [Fact]
+ [Test]
public async Task RevertRowSuccess()
{
// Setup:
@@ -608,16 +603,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// If: I revert the row that has a pending update
s.RevertRow(0);
- // Then:
- // ... The edit cache should not contain a pending edit for the row
- Assert.DoesNotContain(0, s.EditCache.Keys);
+ Assert.That(s.EditCache.Keys, Has.No.Zero, "The edit cache should not contain a pending edit for the row");
}
#endregion
#region Revert Cell Tests
- [Fact]
+ [Test]
public void RevertCellNotInitialized()
{
// Setup:
@@ -630,7 +623,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.RevertCell(0, 0));
}
- [Fact]
+ [Test]
public async Task RevertCellRowRevert()
{
// Setup:
@@ -651,14 +644,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
mockEdit.Verify(e => e.RevertCell(0), Times.Once);
// ... The mock update should no longer be in the edit cache
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
#endregion
#region Update Cell Tests
- [Fact]
+ [Test]
public void UpdateCellNotInitialized()
{
// Setup:
@@ -671,7 +664,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.UpdateCell(0, 0, ""));
}
- [Fact]
+ [Test]
public async Task UpdateCellExisting()
{
// Setup:
@@ -690,10 +683,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The mock update should still be in the cache
// ... And it should have had set cell called on it
- Assert.Contains(mockEdit.Object, s.EditCache.Values);
+ Assert.That(s.EditCache.Values, Has.Member(mockEdit.Object));
}
- [Fact]
+ [Test]
public async Task UpdateCellNew()
{
// Setup:
@@ -704,12 +697,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
s.UpdateCell(0, 0, "");
// Then:
- // ... A new update row edit should have been added to the cache
- Assert.Contains(0, s.EditCache.Keys);
- Assert.IsType(s.EditCache[0]);
+ Assert.Multiple(() =>
+ {
+ Assert.That(s.EditCache.Keys, Has.Member(0));
+ Assert.That(s.EditCache[0], Is.InstanceOf(), "A new update row edit should have been added to the cache");
+ });
}
- [Fact]
+ [Test]
public async Task UpdateCellRowRevert()
{
// Setup:
@@ -730,7 +725,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
mockEdit.Verify(e => e.SetCell(0, null), Times.Once);
// ... The mock update should no longer be in the edit cache
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
@@ -739,7 +734,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region SubSet Tests
- [Fact]
+ [Test]
public async Task SubsetNotInitialized()
{
// Setup:
@@ -749,10 +744,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// If: I ask to update a cell without initializing
// Then: I should get an exception
- await Assert.ThrowsAsync(() => s.GetRows(0, 100));
+ Assert.ThrowsAsync(() => s.GetRows(0, 100));
}
- [Fact]
+ [Test]
public async Task GetRowsNoEdits()
{
// Setup: Create a session with a proper query and metadata
@@ -766,7 +761,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... I should get back 3 rows
- Assert.Equal(3, rows.Length);
+ Assert.AreEqual(3, rows.Length);
// ... Each row should...
for (int i = 0; i < rows.Length; i++)
@@ -774,25 +769,25 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
EditRow er = rows[i];
// ... Have properly set IDs
- Assert.Equal(i + 1, er.Id);
+ Assert.AreEqual(i + 1, er.Id);
// ... Have cells equal to the cells in the result set
DbCellValue[] cachedRow = rs.GetRow(i + 1).ToArray();
- Assert.Equal(cachedRow.Length, er.Cells.Length);
+ Assert.AreEqual(cachedRow.Length, er.Cells.Length);
for (int j = 0; j < cachedRow.Length; j++)
{
- Assert.Equal(cachedRow[j].DisplayValue, er.Cells[j].DisplayValue);
- Assert.Equal(cachedRow[j].IsNull, er.Cells[j].IsNull);
+ Assert.AreEqual(cachedRow[j].DisplayValue, er.Cells[j].DisplayValue);
+ Assert.AreEqual(cachedRow[j].IsNull, er.Cells[j].IsNull);
Assert.False(er.Cells[j].IsDirty);
}
// ... Be clean, since we didn't apply any updates
- Assert.Equal(EditRow.EditRowState.Clean, er.State);
+ Assert.AreEqual(EditRow.EditRowState.Clean, er.State);
Assert.False(er.IsDirty);
}
}
- [Fact]
+ [Test]
public async Task GetRowsPendingUpdate()
{
// Setup:
@@ -807,22 +802,22 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... I should get back 3 rows
- Assert.Equal(3, rows.Length);
+ Assert.AreEqual(3, rows.Length);
// ... The first row should reflect that there is an update pending
// (More in depth testing is done in the RowUpdate class tests)
var updatedRow = rows[0];
- Assert.Equal(EditRow.EditRowState.DirtyUpdate, updatedRow.State);
- Assert.Equal("foo", updatedRow.Cells[0].DisplayValue);
+ Assert.AreEqual(EditRow.EditRowState.DirtyUpdate, updatedRow.State);
+ Assert.AreEqual("foo", updatedRow.Cells[0].DisplayValue);
// ... The other rows should be clean
for (int i = 1; i < rows.Length; i++)
{
- Assert.Equal(EditRow.EditRowState.Clean, rows[i].State);
+ Assert.AreEqual(EditRow.EditRowState.Clean, rows[i].State);
}
}
- [Fact]
+ [Test]
public async Task GetRowsPendingDeletion()
{
// Setup:
@@ -837,22 +832,22 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... I should get back 3 rows
- Assert.Equal(3, rows.Length);
+ Assert.AreEqual(3, rows.Length);
// ... The first row should reflect that there is an update pending
// (More in depth testing is done in the RowUpdate class tests)
var updatedRow = rows[0];
- Assert.Equal(EditRow.EditRowState.DirtyDelete, updatedRow.State);
- Assert.NotEmpty(updatedRow.Cells[0].DisplayValue);
+ Assert.AreEqual(EditRow.EditRowState.DirtyDelete, updatedRow.State);
+ Assert.That(updatedRow.Cells[0].DisplayValue, Is.Not.Empty);
// ... The other rows should be clean
for (int i = 1; i < rows.Length; i++)
{
- Assert.Equal(EditRow.EditRowState.Clean, rows[i].State);
+ Assert.AreEqual(EditRow.EditRowState.Clean, rows[i].State);
}
}
- [Fact]
+ [Test]
public async Task GetRowsPendingInsertion()
{
// Setup:
@@ -867,20 +862,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... I should get back 6 rows
- Assert.Equal(6, rows.Length);
+ Assert.AreEqual(6, rows.Length);
// ... The last row should reflect that there's a new row
var updatedRow = rows[5];
- Assert.Equal(EditRow.EditRowState.DirtyInsert, updatedRow.State);
+ Assert.AreEqual(EditRow.EditRowState.DirtyInsert, updatedRow.State);
// ... The other rows should be clean
for (int i = 0; i < rows.Length - 1; i++)
{
- Assert.Equal(EditRow.EditRowState.Clean, rows[i].State);
+ Assert.AreEqual(EditRow.EditRowState.Clean, rows[i].State);
}
}
- [Fact]
+ [Test]
public async Task GetRowsAllNew()
{
// Setup:
@@ -897,17 +892,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... I should get back 3 rows back
- Assert.Equal(3, rows.Length);
+ Assert.AreEqual(3, rows.Length);
- // ... All the rows should be new
- Assert.All(rows, r => Assert.Equal(EditRow.EditRowState.DirtyInsert, r.State));
+ Assert.That(rows.Select(r => r.State), Has.All.EqualTo(EditRow.EditRowState.DirtyInsert), "All the rows should be new");
}
#endregion
#region Script Edits Tests
- [Fact]
+ [Test]
public void ScriptEditsNotInitialized()
{
// Setup:
@@ -920,11 +914,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.ScriptEdits(string.Empty));
}
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData(" \t\r\n")]
- public async Task ScriptNullOrEmptyOutput(string outputPath)
+ [Test]
+ public async Task ScriptNullOrEmptyOutput([Values(null, "", " \t\r\n")] string outputPath)
{
// Setup: Create a session with a proper query and metadata
EditSession s = await GetBasicSession();
@@ -934,7 +925,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.ScriptEdits(outputPath));
}
- [Fact]
+ [Test]
public async Task ScriptProvidedOutputPath()
{
// Setup:
@@ -954,10 +945,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Then:
// ... The output path used should be the same as the one we provided
- Assert.Equal(file.FilePath, outputPath);
+ Assert.AreEqual(file.FilePath, outputPath);
// ... The written file should have two lines, one for each edit
- Assert.Equal(2, File.ReadAllLines(outputPath).Length);
+ Assert.AreEqual(2, File.ReadAllLines(outputPath).Length);
}
}
@@ -965,7 +956,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
#region Commit Tests
- [Fact]
+ [Test]
public void CommitEditsNotInitialized()
{
// Setup:
@@ -978,7 +969,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.CommitEdits(null, null, null));
}
- [Fact]
+ [Test]
public async Task CommitNullConnection()
{
// Setup: Create a basic session
@@ -990,7 +981,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
() => s.CommitEdits(null, () => Task.CompletedTask, e => Task.CompletedTask));
}
- [Fact]
+ [Test]
public async Task CommitNullSuccessHandler()
{
// Setup:
@@ -1005,7 +996,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.CommitEdits(conn, null, e => Task.CompletedTask));
}
- [Fact]
+ [Test]
public async Task CommitNullFailureHandler()
{
// Setup:
@@ -1020,7 +1011,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => s.CommitEdits(conn, () => Task.CompletedTask, null));
}
- [Fact]
+ [Test]
public async Task CommitInProgress()
{
// Setup:
@@ -1038,7 +1029,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
() => s.CommitEdits(conn, () => Task.CompletedTask, e => Task.CompletedTask));
}
- [Fact]
+ [Test]
public async Task CommitSuccess()
{
// Setup:
@@ -1079,10 +1070,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
edit.Verify(e => e.ApplyChanges(It.IsAny()), Times.Once);
// ... The edit cache should be empty
- Assert.Empty(s.EditCache);
+ Assert.That(s.EditCache, Is.Empty);
}
- [Fact]
+ [Test]
public async Task CommitFailure()
{
// Setup:
@@ -1121,14 +1112,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
edit.Verify(e => e.GetCommand(conn), Times.Once);
// ... The edit cache should not be empty
- Assert.NotEmpty(s.EditCache);
+ Assert.That(s.EditCache, Is.Not.Empty);
}
#endregion
#region Construct Initialize Query Tests
- [Fact]
+ [Test]
public void ConstructQueryWithoutLimit()
{
// Setup: Create a metadata provider for some basic columns
@@ -1148,16 +1139,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(match.Success);
// ... There should be columns in it
- Assert.Equal(data.DbColumns.Length, match.Groups[1].Value.Split(',').Length);
+ Assert.AreEqual(data.DbColumns.Length, match.Groups[1].Value.Split(',').Length);
// ... The table name should be in it
- Assert.Equal(data.TableMetadata.EscapedMultipartName, match.Groups[2].Value);
+ Assert.AreEqual(data.TableMetadata.EscapedMultipartName, match.Groups[2].Value);
- // ... It should NOT have a TOP clause in it
- Assert.DoesNotContain("TOP", query);
+ Assert.That(query, Does.Not.Contain("TOP"), "It should NOT have a TOP clause in it");
}
- [Fact]
+ [Test]
public void ConstructQueryNegativeLimit()
{
// Setup: Create a metadata provider for some basic columns
@@ -1172,11 +1162,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws(() => EditSession.ConstructInitializeQuery(data.TableMetadata, eif));
}
- [Theory]
- [InlineData(0)] // Yes, zero is valid
- [InlineData(10)]
- [InlineData(1000)]
- public void ConstructQueryWithLimit(int limit)
+ [Test]
+ public void ConstructQueryWithLimit([Values(0,10,1000)]int limit)
{
// Setup: Create a metadata provider for some basic columns
var data = new Common.TestDbColumnsWithTableMetadata(false, false, 0, 0);
@@ -1195,15 +1182,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.True(match.Success);
// ... There should be columns in it
- Assert.Equal(data.DbColumns.Length, match.Groups[2].Value.Split(',').Length);
+ Assert.AreEqual(data.DbColumns.Length, match.Groups[2].Value.Split(',').Length);
// ... The table name should be in it
- Assert.Equal(data.TableMetadata.EscapedMultipartName, match.Groups[3].Value);
+ Assert.AreEqual(data.TableMetadata.EscapedMultipartName, match.Groups[3].Value);
// ... The top count should be equal to what we provided
int limitFromQuery;
Assert.True(int.TryParse(match.Groups[1].Value, out limitFromQuery));
- Assert.Equal(limit, limitFromQuery);
+ Assert.AreEqual(limit, limitFromQuery);
}
#endregion
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ExtensionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ExtensionTests.cs
index 203ebcef..4bfbcfec 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ExtensionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ExtensionTests.cs
@@ -9,51 +9,51 @@ using System.Linq;
using System.Reflection;
using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
{
public class ExtensionTests
{
- [Fact]
+ [Test]
public void CreateAssemblyStoreShouldFindTypesInAssembly()
{
// Given a store for MyExportType
ExtensionStore store = ExtensionStore.CreateAssemblyStore(GetType().GetTypeInfo().Assembly);
// Then should get any export for this type and subtypes
- Assert.Equal(2, store.GetExports().Count());
+ Assert.AreEqual(2, store.GetExports().Count());
// But for a different type, expect throw as the store only contains MyExportType
Assert.Throws(() => store.GetExports().Count());
}
- [Fact]
+ [Test]
public void CreateDefaultLoaderShouldFindTypesOnlyInMainAssembly()
{
// Given a store created using CreateDefaultLoader
// Then not should find exports from a different assembly
ExtensionStore store = ExtensionStore.CreateDefaultLoader();
- Assert.Equal(0, store.GetExports().Count());
+ Assert.AreEqual(0, store.GetExports().Count());
// And should not find exports that are defined in the ServiceLayer assembly
store = ExtensionStore.CreateDefaultLoader();
- Assert.Empty(store.GetExports());
+ Assert.That(store.GetExports(), Is.Empty);
}
- [Fact]
+ [Test]
public void CreateDefaultServiceProviderShouldFindTypesInAllKnownAssemblies()
{
// Given a default ExtensionServiceProvider
// Then we should not find exports from a test assembly
ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider();
- Assert.Empty(serviceProvider.GetServices());
+ Assert.That(serviceProvider.GetServices(), Is.Empty);
// But should find exports that are defined in the main assembly
- Assert.NotEmpty(serviceProvider.GetServices());
+ Assert.That(serviceProvider.GetServices(), Is.Not.Empty);
}
- // [Fact]
+ // [Test]
public void CreateStoreForCurrentDirectoryShouldFindExportsInDirectory()
{
// Given stores created for types in different assemblies
@@ -62,8 +62,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
// When I query exports
// Then exports for all assemblies should be found
- Assert.Equal(2, myStore.GetExports().Count());
- Assert.NotEmpty(querierStore.GetExports());
+ Assert.AreEqual(2, myStore.GetExports().Count());
+ Assert.That(querierStore.GetExports(), Is.Not.Empty);
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ServiceProviderTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ServiceProviderTests.cs
index f55aff15..038d04c0 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ServiceProviderTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Extensibility/ServiceProviderTests.cs
@@ -6,19 +6,21 @@
using System;
using System.Linq;
using Microsoft.SqlTools.Extensibility;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
{
public class ServiceProviderTests
{
private RegisteredServiceProvider provider;
- public ServiceProviderTests()
+
+ [SetUp]
+ public void InitServiceProviderTests()
{
provider = new RegisteredServiceProvider();
}
- [Fact]
+ [Test]
public void GetServiceShouldReturnNullIfNoServicesRegistered()
{
// Given no service registered
@@ -29,7 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
}
- [Fact]
+ [Test]
public void GetSingleServiceThrowsMultipleServicesRegistered()
{
// Given 2 services registered
@@ -39,7 +41,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
Assert.Throws(() => provider.GetService());
}
- [Fact]
+ [Test]
public void GetServicesShouldReturnEmptyIfNoServicesRegistered()
{
// Given no service regisstered
@@ -47,36 +49,36 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
var services = provider.GetServices();
// Then I expect empty enumerable to be returned
Assert.NotNull(services);
- Assert.Equal(0, services.Count());
+ Assert.AreEqual(0, services.Count());
}
- [Fact]
+ [Test]
public void GetServiceShouldReturnRegisteredService()
{
MyProviderService service = new MyProviderService();
provider.RegisterSingleService(service);
var returnedService = provider.GetService();
- Assert.Equal(service, returnedService);
+ Assert.AreEqual(service, returnedService);
}
- [Fact]
+ [Test]
public void GetServicesShouldReturnRegisteredServiceWhenMultipleServicesRegistered()
{
MyProviderService service = new MyProviderService();
provider.RegisterSingleService(service);
var returnedServices = provider.GetServices();
- Assert.Equal(service, returnedServices.Single());
+ Assert.AreEqual(service, returnedServices.Single());
}
- [Fact]
+ [Test]
public void RegisterServiceProviderShouldThrowIfServiceIsIncompatible()
{
MyProviderService service = new MyProviderService();
Assert.Throws(() => provider.RegisterSingleService(typeof(OtherService), service));
}
- [Fact]
+ [Test]
public void RegisterServiceProviderShouldThrowIfServiceAlreadyRegistered()
{
MyProviderService service = new MyProviderService();
@@ -85,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
Assert.Throws(() => provider.RegisterSingleService(service));
}
- [Fact]
+ [Test]
public void RegisterShouldThrowIfServiceAlreadyRegistered()
{
MyProviderService service = new MyProviderService();
@@ -94,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Extensibility
Assert.Throws(() => provider.Register(() => service.SingleItemAsEnumerable()));
}
- [Fact]
+ [Test]
public void RegisterShouldThrowIfServicesAlreadyRegistered()
{
provider.Register(() => new [] { new MyProviderService(), new MyProviderService() });
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/FileBrowser/FileBrowserTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/FileBrowser/FileBrowserTests.cs
index 5e1fd8c9..fdefa686 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/FileBrowser/FileBrowserTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/FileBrowser/FileBrowserTests.cs
@@ -6,7 +6,7 @@
using System;
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
using Microsoft.SqlTools.ServiceLayer.FileBrowser.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
{
@@ -15,7 +15,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
///
public class FileBrowserTests
{
- [Fact]
+ [Test]
public void CreateFileBrowserOperationTest()
{
FileBrowserOperation operation = new FileBrowserOperation(null, "", null);
@@ -25,7 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
Assert.True(operation.FileFilters.Length == 1);
}
- [Fact]
+ [Test]
public void FilterFilesTest()
{
FileBrowserOperation operation = new FileBrowserOperation(null, "", null);
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
}
}
- [Fact]
+ [Test]
public void ExpandNodeShouldThrowExceptionForInvalidPath()
{
FileBrowserOperation operation = new FileBrowserOperation(null, "", null);
@@ -64,7 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
Assert.Null(operation.FileTree.SelectedNode);
}
- [Fact]
+ [Test]
public void CreateFileTreeTest()
{
FileTree tree = new FileTree();
@@ -72,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.FileBrowser
Assert.Null(tree.SelectedNode);
}
- [Fact]
+ [Test]
public void AddFileTreeNodeChildTest()
{
FileTreeNode node1 = new FileTreeNode();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/BinaryQueryExpressionFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/BinaryQueryExpressionFormatterTests.cs
index 51b31ee9..306756c4 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/BinaryQueryExpressionFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/BinaryQueryExpressionFormatterTests.cs
@@ -4,13 +4,19 @@
//
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class BinaryQueryExpressionFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void BQE_IndentOperands()
{
FormatOptions options = new FormatOptions();
@@ -19,7 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("BQE_IndentOperands.sql"), options, true);
}
- [Fact]
+ [Test]
public void BQE_KeywordCasing_UpperCase()
{
FormatOptions options = new FormatOptions();
@@ -28,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("BQE_KeywordCasing_UpperCase.sql"), options, true);
}
- [Fact]
+ [Test]
public void BQE_KeywordCasing_LowerCase()
{
FormatOptions options = new FormatOptions();
@@ -37,7 +43,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("BQE_KeywordCasing_LowerCase.sql"), options, true);
}
- [Fact]
+ [Test]
public void BQE_KeywordCasing_NoFormat()
{
FormatOptions options = new FormatOptions();
@@ -46,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("BQE_KeywordCasing_NoFormat.sql"), options, true);
}
- [Fact]
+ [Test]
public void BQE_OperatorsOnNewLine()
{
FormatOptions options = new FormatOptions();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CommonTableExpressionFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CommonTableExpressionFormatterTests.cs
index 6f5cdaac..deca953e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CommonTableExpressionFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CommonTableExpressionFormatterTests.cs
@@ -5,35 +5,41 @@
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class CommonTableExpressionFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void CTE()
{
LoadAndFormatAndCompare("CTE", GetInputFile("CTE.sql"),
GetBaselineFile("CTE.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CTE_OneColumn()
{
LoadAndFormatAndCompare("CTE_OneColumn", GetInputFile("CTE_OneColumn.sql"),
GetBaselineFile("CTE_OneColumn.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CTE_MultipleExpressions()
{
LoadAndFormatAndCompare("CTE_MultipleExpressions", GetInputFile("CTE_MultipleExpressions.sql"),
GetBaselineFile("CTE_MultipleExpressions.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CTE_CommasBeforeDefinition()
{
FormatOptions options = new FormatOptions();
@@ -44,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_CommasBeforeDefinition.sql"), options, false);
}
- [Fact]
+ [Test]
public void CTE_EachReferenceOnNewLine()
{
FormatOptions options = new FormatOptions();
@@ -54,7 +60,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_EachReferenceOnNewLine.sql"), options, true);
}
- [Fact]
+ [Test]
public void CTE_EachReferenceOnNewLine_CommasBeforeDefinition()
{
FormatOptions options = new FormatOptions();
@@ -66,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_EachReferenceOnNewLine_CommasBeforeDefinition.sql"), options, false);
}
- [Fact]
+ [Test]
public void CTE_UseTabs()
{
FormatOptions options = new FormatOptions();
@@ -76,7 +82,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_UseTabs.sql"), options, true);
}
- [Fact]
+ [Test]
public void CTE_20Spaces()
{
FormatOptions options = new FormatOptions();
@@ -86,7 +92,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_20Spaces.sql"), options, true);
}
- [Fact]
+ [Test]
public void CTE_UpperCaseKeywords()
{
FormatOptions options = new FormatOptions();
@@ -96,7 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("CTE_UpperCaseKeywords.sql"), options, true);
}
- [Fact]
+ [Test]
public void CTE_LowerCaseKeywords()
{
FormatOptions options = new FormatOptions();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateProcedureFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateProcedureFormatterTests.cs
index 173fa415..b1193591 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateProcedureFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateProcedureFormatterTests.cs
@@ -4,69 +4,75 @@
//
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class CreateProcedureFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void CreateProcedure_BackwardsCompatible()
{
LoadAndFormatAndCompare("CreateProcedure_BackwardsCompatible", GetInputFile("CreateProcedure_BackwardsCompatible.sql"),
GetBaselineFile("CreateProcedure_BackwardsCompatible.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_BeginEnd()
{
LoadAndFormatAndCompare("CreateProcedure_BeginEnd", GetInputFile("CreateProcedure_BeginEnd.sql"),
GetBaselineFile("CreateProcedure_BeginEnd.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_Minimal()
{
LoadAndFormatAndCompare("CreateProcedure_Minimal", GetInputFile("CreateProcedure_Minimal.sql"),
GetBaselineFile("CreateProcedure_Minimal.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_MultipleBatches()
{
LoadAndFormatAndCompare("CreateProcedure_MultipleBatches", GetInputFile("CreateProcedure_MultipleBatches.sql"),
GetBaselineFile("CreateProcedure_MultipleBatches.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_MultipleParams()
{
LoadAndFormatAndCompare("CreateProcedure_MultipleParams", GetInputFile("CreateProcedure_MultipleParams.sql"),
GetBaselineFile("CreateProcedure_MultipleParams.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_OneParam()
{
LoadAndFormatAndCompare("CreateProcedure_OneParam", GetInputFile("CreateProcedure_OneParam.sql"),
GetBaselineFile("CreateProcedure_OneParam.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_ParamsRecompileReturn()
{
LoadAndFormatAndCompare("CreateProcedure_ParamsRecompileReturn", GetInputFile("CreateProcedure_ParamsRecompileReturn.sql"),
GetBaselineFile("CreateProcedure_ParamsRecompileReturn.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_Select()
{
LoadAndFormatAndCompare("CreateProcedure_Select", GetInputFile("CreateProcedure_Select.sql"),
GetBaselineFile("CreateProcedure_Select.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_CommaBeforeNextColumn()
{
// Verifies that commas are placed before the next column instead of after the current one,
@@ -83,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
}, true);
}
- [Fact]
+ [Test]
public void CreateProcedure_CommaBeforeNextColumnRepeated()
{
// Verifies that formatting isn't changed for text that's already been formatted
@@ -101,7 +107,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
true);
}
- [Fact]
+ [Test]
public void CreateProcedure_CommaBeforeNextColumnNoNewline()
{
// Verifies that commas are placed before the next column instead of after the current one,
@@ -119,35 +125,35 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
}, true);
}
- [Fact]
+ [Test]
public void CreateProcedure_TwoPartName()
{
LoadAndFormatAndCompare("CreateProcedure_TwoPartName", GetInputFile("CreateProcedure_TwoPartName.sql"),
GetBaselineFile("CreateProcedure_TwoPartName.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_WithCTE()
{
LoadAndFormatAndCompare("CreateProcedure_WithCTE", GetInputFile("CreateProcedure_WithCTE.sql"),
GetBaselineFile("CreateProcedure_WithCTE.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_WithEncryptionModule()
{
LoadAndFormatAndCompare("CreateProcedure_WithEncryptionModule", GetInputFile("CreateProcedure_WithEncryptionModule.sql"),
GetBaselineFile("CreateProcedure_WithEncryptionModule.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_WithExecuteAsModule()
{
LoadAndFormatAndCompare("CreateProcedure_WithExecuteAsModule", GetInputFile("CreateProcedure_WithExecuteAsModule.sql"),
GetBaselineFile("CreateProcedure_WithExecuteAsModule.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateProcedure_WithThreeModules()
{
LoadAndFormatAndCompare("CreateProcedure_WithThreeModules", GetInputFile("CreateProcedure_WithThreeModules.sql"),
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateTableFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateTableFormatterTests.cs
index cbf5fb7c..f65f3349 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateTableFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateTableFormatterTests.cs
@@ -4,14 +4,20 @@
//
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class CreateTableFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void CreateTable()
{
LoadAndFormatAndCompare("CreateTable", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable.sql"), new FormatOptions(), true);
@@ -20,7 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
/**
* The test contains a timestamp column, which is the shortest (1 token) possible length for a column item.
*/
- [Fact]
+ [Test]
public void CreateTable_Timestamp()
{
FormatOptions options = new FormatOptions();
@@ -28,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_Timestamp", GetInputFile("CreateTable_Timestamp.sql"), GetBaselineFile("CreateTable_Timestamp.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_CommasBeforeDefinition()
{
FormatOptions options = new FormatOptions();
@@ -38,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_CommasBeforeDefinition", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_CommasBeforeDefinition.sql"), options, false);
}
- [Fact]
+ [Test]
public void CreateTable_UseTabs()
{
FormatOptions options = new FormatOptions();
@@ -46,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_UseTabs", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_UseTabs.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_20Spaces()
{
FormatOptions options = new FormatOptions();
@@ -54,7 +60,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_20Spaces", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_20Spaces.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_UpperCaseKeywords()
{
FormatOptions options = new FormatOptions();
@@ -62,7 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_UpperCaseKeywords", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_UpperCaseKeywords.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_LowerCaseKeywords()
{
FormatOptions options = new FormatOptions();
@@ -70,7 +76,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_LowerCaseKeywords", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_LowerCaseKeywords.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_UpperCaseDataTypes()
{
FormatOptions options = new FormatOptions();
@@ -78,7 +84,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_UpperCaseDataTypes", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_UpperCaseDataTypes.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_LowerCaseDataTypes()
{
FormatOptions options = new FormatOptions();
@@ -86,14 +92,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_LowerCaseDataTypes", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_LowerCaseDataTypes.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_AlignInColumns()
{
FormatOptions options = new FormatOptions() { AlignColumnDefinitionsInColumns = true };
LoadAndFormatAndCompare("CreateTable_AlignInColumns", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_AlignInColumns.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_AlignInColumnsUseTabs()
{
FormatOptions options = new FormatOptions();
@@ -102,19 +108,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_AlignInColumnsUseTabs", GetInputFile("CreateTable.sql"), GetBaselineFile("CreateTable_AlignInColumnsUseTabs.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTable_On()
{
LoadAndFormatAndCompare("CreateTableOn", GetInputFile("CreateTableFull.sql"), GetBaselineFile("CreateTableOn.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateTable_Formatted()
{
LoadAndFormatAndCompare("CreateTable_Formatted", GetInputFile("CreateTable_Formatted.sql"), GetBaselineFile("CreateTable_Formatted.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateTable_CommentsBeforeComma()
{
FormatOptions options = new FormatOptions();
@@ -124,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTable_CommentsBeforeComma", GetInputFile("CreateTable_CommentBeforeComma.sql"), GetBaselineFile("CreateTable_CommentBeforeComma.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTableAddress_AlignInColumns()
{
FormatOptions options = new FormatOptions();
@@ -132,7 +138,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LoadAndFormatAndCompare("CreateTableAddress_AlignInColumns", GetInputFile("Address.sql"), GetBaselineFile("CreateTableAddress_AlignInColumns.sql"), options, true);
}
- [Fact]
+ [Test]
public void CreateTableAddress_AlignInColumnsUseTabs()
{
FormatOptions options = new FormatOptions();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateViewFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateViewFormatterTests.cs
index 18d07239..c25f585d 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateViewFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/CreateViewFormatterTests.cs
@@ -5,62 +5,68 @@
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class CreateViewFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void CreateView_Full()
{
LoadAndFormatAndCompare("CreateView_Full", GetInputFile("CreateView_Full.sql"),
GetBaselineFile("CreateView_Full.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_FullWithComments()
{
LoadAndFormatAndCompare("CreateView_FullWithComments", GetInputFile("CreateView_FullWithComments.sql"), GetBaselineFile("CreateView_FullWithComments.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_MultipleColumns()
{
LoadAndFormatAndCompare("CreateView_MultipleColumns", GetInputFile("CreateView_MultipleColumns.sql"),
GetBaselineFile("CreateView_MultipleColumns.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_MultipleOptions()
{
LoadAndFormatAndCompare("CreateView_MultipleOptions", GetInputFile("CreateView_MultipleOptions.sql"),
GetBaselineFile("CreateView_MultipleOptions.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_OneColumn()
{
LoadAndFormatAndCompare("CreateView_OneColumn", GetInputFile("CreateView_OneColumn.sql"),
GetBaselineFile("CreateView_OneColumn.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_OneColumnOneOption()
{
LoadAndFormatAndCompare("CreateView_OneColumnOneOption", GetInputFile("CreateView_OneColumnOneOption.sql"),
GetBaselineFile("CreateView_OneColumnOneOption.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_OneOption()
{
LoadAndFormatAndCompare("CreateView_OneOption", GetInputFile("CreateView_OneOption.sql"),
GetBaselineFile("CreateView_OneOption.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void CreateView_Simple()
{
LoadAndFormatAndCompare("CreateView_Simple", GetInputFile("CreateView_Simple.sql"),
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterSettingsTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterSettingsTests.cs
index 6da2dc94..5a943880 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterSettingsTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterSettingsTests.cs
@@ -8,25 +8,25 @@ using Microsoft.SqlTools.ServiceLayer.Formatter;
using Microsoft.SqlTools.ServiceLayer.Formatter.Contracts;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Newtonsoft.Json.Linq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class FormatterSettingsTests
{
- [Fact]
+ [Test]
public void ValidateFormatterServiceDefaults()
{
var sqlToolsSettings = new SqlToolsSettings();
Assert.Null(sqlToolsSettings.SqlTools.Format.AlignColumnDefinitionsInColumns);
- Assert.Equal(CasingOptions.None, sqlToolsSettings.SqlTools.Format.DatatypeCasing);
- Assert.Equal(CasingOptions.None, sqlToolsSettings.SqlTools.Format.KeywordCasing);
+ Assert.AreEqual(CasingOptions.None, sqlToolsSettings.SqlTools.Format.DatatypeCasing);
+ Assert.AreEqual(CasingOptions.None, sqlToolsSettings.SqlTools.Format.KeywordCasing);
Assert.Null(sqlToolsSettings.SqlTools.Format.PlaceCommasBeforeNextStatement);
Assert.Null(sqlToolsSettings.SqlTools.Format.PlaceSelectStatementReferencesOnNewLine);
Assert.Null(sqlToolsSettings.SqlTools.Format.UseBracketForIdentifiers);
}
- [Fact]
+ [Test]
public void ValidateFormatSettingsParsedFromJson()
{
ValidateFormatSettings("mssql");
@@ -57,14 +57,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
SqlToolsSettings sqlToolsSettings = messageParams.ToObject();
Assert.True(sqlToolsSettings.SqlTools.Format.AlignColumnDefinitionsInColumns);
- Assert.Equal(CasingOptions.Lowercase, sqlToolsSettings.SqlTools.Format.DatatypeCasing);
- Assert.Equal(CasingOptions.Uppercase, sqlToolsSettings.SqlTools.Format.KeywordCasing);
+ Assert.AreEqual(CasingOptions.Lowercase, sqlToolsSettings.SqlTools.Format.DatatypeCasing);
+ Assert.AreEqual(CasingOptions.Uppercase, sqlToolsSettings.SqlTools.Format.KeywordCasing);
Assert.True(sqlToolsSettings.SqlTools.Format.PlaceCommasBeforeNextStatement);
Assert.True(sqlToolsSettings.SqlTools.Format.PlaceSelectStatementReferencesOnNewLine);
Assert.True(sqlToolsSettings.SqlTools.Format.UseBracketForIdentifiers);
}
- [Fact]
+ [Test]
public void FormatOptionsMatchDefaultSettings()
{
var options = new FormatOptions();
@@ -74,14 +74,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
private static void AssertOptionsHaveDefaultValues(FormatOptions options)
{
Assert.False(options.AlignColumnDefinitionsInColumns);
- Assert.Equal(CasingOptions.None, options.DatatypeCasing);
- Assert.Equal(CasingOptions.None, options.KeywordCasing);
+ Assert.AreEqual(CasingOptions.None, options.DatatypeCasing);
+ Assert.AreEqual(CasingOptions.None, options.KeywordCasing);
Assert.False(options.PlaceCommasBeforeNextStatement);
Assert.False(options.PlaceEachReferenceOnNewLineInQueryStatements);
Assert.False(options.EncloseIdentifiersInSquareBrackets);
}
- [Fact]
+ [Test]
public void CanCopyDefaultFormatSettingsToOptions()
{
var sqlToolsSettings = new SqlToolsSettings();
@@ -90,7 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
AssertOptionsHaveDefaultValues(options);
}
- [Fact]
+ [Test]
public void CanCopyAlteredFormatSettingsToOptions()
{
SqlToolsSettings sqlToolsSettings = CreateNonDefaultFormatSettings();
@@ -116,8 +116,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
private static void AssertOptionsHaveExpectedNonDefaultValues(FormatOptions options)
{
Assert.True(options.AlignColumnDefinitionsInColumns);
- Assert.Equal(CasingOptions.Lowercase, options.DatatypeCasing);
- Assert.Equal(CasingOptions.Uppercase, options.KeywordCasing);
+ Assert.AreEqual(CasingOptions.Lowercase, options.DatatypeCasing);
+ Assert.AreEqual(CasingOptions.Uppercase, options.KeywordCasing);
Assert.True(options.PlaceCommasBeforeNextStatement);
Assert.True(options.PlaceEachReferenceOnNewLineInQueryStatements);
Assert.True(options.EncloseIdentifiersInSquareBrackets);
@@ -130,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
Assert.False(options.DoNotFormatKeywords);
}
- [Fact]
+ [Test]
public void CanMergeRequestOptionsAndSettings()
{
var sqlToolsSettings = CreateNonDefaultFormatSettings();
@@ -142,7 +142,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
AssertOptionsHaveExpectedNonDefaultValues(options);
Assert.False(options.UseTabs);
Assert.True(options.UseSpaces);
- Assert.Equal(2, options.SpacesPerIndent);
+ Assert.AreEqual(2, options.SpacesPerIndent);
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterUnitTestBase.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterUnitTestBase.cs
index 8cefa3ba..0ec6dc30 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterUnitTestBase.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/FormatterUnitTestBase.cs
@@ -18,7 +18,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class FormatterUnitTestsBase
{
- public FormatterUnitTestsBase()
+ protected void InitFormatterUnitTestsBase()
{
HostMock = new Mock();
WorkspaceServiceMock = new Mock>();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/GeneralFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/GeneralFormatterTests.cs
index 63e4363c..e63e5b0f 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/GeneralFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/GeneralFormatterTests.cs
@@ -4,13 +4,19 @@
//
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class GeneralFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void GoNewLineShouldBePreserved()
{
LoadAndFormatAndCompare("GoNewLineShouldBePreserved",
@@ -24,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verifyFormat: true);
}
- [Fact]
+ [Test]
public void KeywordCaseConversionUppercase()
{
LoadAndFormatAndCompare("KeywordCaseConversion",
@@ -34,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verifyFormat: true);
}
- [Fact]
+ [Test]
public void KeywordCaseConversionLowercase()
{
LoadAndFormatAndCompare("KeywordCaseConversion",
@@ -44,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verifyFormat: true);
}
- [Fact]
+ [Test]
public void SelectWithOrderByShouldCorrectlyIndent()
{
LoadAndFormatAndCompare("SelectWithOrderByShouldCorrectlyIndent",
@@ -54,7 +60,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verifyFormat: true);
}
- [Fact]
+ [Test]
public void SelectStatementShouldCorrectlyIndent()
{
LoadAndFormatAndCompare("SelectStatementShouldCorrectlyIndent",
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/InsertFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/InsertFormatterTests.cs
index c18ba630..1c922bce 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/InsertFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/InsertFormatterTests.cs
@@ -5,42 +5,48 @@
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class InsertFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void Insert_DefaultValues()
{
LoadAndFormatAndCompare("Insert_DefaultValues", GetInputFile("Insert_DefaultValues.sql"),
GetBaselineFile("Insert_DefaultValues.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_OpenQuery()
{
LoadAndFormatAndCompare("Insert_OpenQuery", GetInputFile("Insert_OpenQuery.sql"),
GetBaselineFile("Insert_OpenQuery.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_OutputInto()
{
LoadAndFormatAndCompare("Insert_OutputInto", GetInputFile("Insert_OutputInto.sql"),
GetBaselineFile("Insert_OutputInto.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_OutputStatement()
{
LoadAndFormatAndCompare("Insert_OutputStatement", GetInputFile("Insert_OutputStatement.sql"),
GetBaselineFile("Insert_OutputStatement.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_Select()
{
FormatOptions options = new FormatOptions();
@@ -49,7 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("Insert_Select.sql"), options, true);
}
- [Fact]
+ [Test]
public void Insert_SelectSource()
{
FormatOptions options = new FormatOptions();
@@ -58,21 +64,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("Insert_SelectSource.sql"), options, true);
}
- [Fact]
+ [Test]
public void Insert_TopSpecification()
{
LoadAndFormatAndCompare("Insert_TopSpecification", GetInputFile("Insert_TopSpecification.sql"),
GetBaselineFile("Insert_TopSpecification.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_TopWithComments()
{
LoadAndFormatAndCompare("Insert_TopWithComments", GetInputFile("Insert_TopWithComments.sql"),
GetBaselineFile("Insert_TopWithComments.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void Insert_Full()
{
LoadAndFormatAndCompare("Insert_Full", GetInputFile("Insert_Full.sql"),
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/SqlSelectStatementFormatterTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/SqlSelectStatementFormatterTests.cs
index c88a7354..4ebec0cc 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/SqlSelectStatementFormatterTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/SqlSelectStatementFormatterTests.cs
@@ -4,21 +4,27 @@
//
using Microsoft.SqlTools.ServiceLayer.Formatter;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class SqlSelectStatementFormatterTests : FormatterUnitTestsBase
{
- [Fact]
+ [SetUp]
+ public void Init()
+ {
+ InitFormatterUnitTestsBase();
+ }
+
+ [Test]
public void SimpleQuery()
{
LoadAndFormatAndCompare("SimpleQuery", GetInputFile("SimpleQuery.sql"),
GetBaselineFile("SimpleQuery.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void SimpleQuery_CommasBeforeDefinition()
{
FormatOptions options = new FormatOptions();
@@ -29,7 +35,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_CommasBeforeDefinition.sql"), options, false);
}
- [Fact]
+ [Test]
public void SimpleQuery_EachReferenceOnNewLine()
{
FormatOptions options = new FormatOptions();
@@ -39,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_EachReferenceOnNewLine.sql"), options, true);
}
- [Fact]
+ [Test]
public void SimpleQuery_EachReferenceOnNewLine_CommasBeforeDefinition()
{
FormatOptions options = new FormatOptions();
@@ -51,7 +57,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetInputFile("SimpleQuery.sql"), GetBaselineFile("SimpleQuery_EachReferenceOnNewLine_CommasBeforeDefinition.sql"), options, false);
}
- [Fact]
+ [Test]
public void SimpleQuery_UseTabs()
{
FormatOptions options = new FormatOptions();
@@ -61,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_UseTabs.sql"), options, true);
}
- [Fact]
+ [Test]
public void SimpleQuery_20Spaces()
{
FormatOptions options = new FormatOptions();
@@ -71,7 +77,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_20Spaces.sql"), options, true);
}
- [Fact]
+ [Test]
public void SimpleQuery_UpperCaseKeywords()
{
FormatOptions options = new FormatOptions();
@@ -81,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_UpperCaseKeywords.sql"), options, true);
}
- [Fact]
+ [Test]
public void SimpleQuery_LowerCaseKeywords()
{
FormatOptions options = new FormatOptions();
@@ -91,14 +97,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
GetBaselineFile("SimpleQuery_LowerCaseKeywords.sql"), options, true);
}
- [Fact]
+ [Test]
public void SimpleQuery_ForBrowseClause()
{
LoadAndFormatAndCompare("SimpleQuery_ForBrowseClause", GetInputFile("SimpleQuery_ForBrowseClause.sql"),
GetBaselineFile("SimpleQuery_ForBrowseClause.sql"), new FormatOptions(), true);
}
- [Fact]
+ [Test]
public void SimpleQuery_ForXmlClause()
{
LoadAndFormatAndCompare("SimpleQuery_ForXmlClause", GetInputFile("SimpleQuery_ForXmlClause.sql"),
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/TSqlFormatterServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/TSqlFormatterServiceTests.cs
index d7ef6cc7..9324c97b 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/TSqlFormatterServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Formatter/TSqlFormatterServiceTests.cs
@@ -16,19 +16,22 @@ using Microsoft.SqlTools.ServiceLayer.Test.Common.RequestContextMocking;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
public class TSqlFormatterServiceTests : FormatterUnitTestsBase
{
- private Mock workspaceMock = new Mock();
+ private Mock workspaceMock;
private TextDocumentIdentifier textDocument;
DocumentFormattingParams docFormatParams;
DocumentRangeFormattingParams rangeFormatParams;
- public TSqlFormatterServiceTests()
+ [SetUp]
+ public void InitTSqlFormatterServiceTests()
{
+ InitFormatterUnitTestsBase();
+ workspaceMock = new Mock();
textDocument = new TextDocumentIdentifier
{
Uri = "script file"
@@ -64,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
LanguageServiceMock.Setup(x => x.ShouldSkipNonMssqlFile(It.IsAny())).Returns(skipFile);
}
- [Fact]
+ [Test]
public async Task FormatDocumentShouldReturnSingleEdit()
{
// Given a document that we want to format
@@ -76,12 +79,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verify: (edits =>
{
// Then expect a single edit to be returned and for it to match the standard formatting
- Assert.Equal(1, edits.Length);
+ Assert.AreEqual(1, edits.Length);
AssertFormattingEqual(formattedSqlContents, edits[0].NewText);
}));
}
- [Fact]
+ [Test]
public async Task FormatDocumentShouldSkipNonMssqlFile()
{
// Given a non-MSSQL document
@@ -93,12 +96,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verify: (edits =>
{
// Then expect a single edit to be returned and for it to match the standard formatting
- Assert.Equal(0, edits.Length);
+ Assert.AreEqual(0, edits.Length);
LanguageServiceMock.Verify(x => x.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri), Times.Once);
}));
}
- [Fact]
+ [Test]
public async Task FormatRangeShouldReturnSingleEdit()
{
// Given a document that we want to format
@@ -110,12 +113,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verify: (edits =>
{
// Then expect a single edit to be returned and for it to match the standard formatting
- Assert.Equal(1, edits.Length);
+ Assert.AreEqual(1, edits.Length);
AssertFormattingEqual(formattedSqlContents, edits[0].NewText);
}));
}
- [Fact]
+ [Test]
public async Task FormatRangeShouldSkipNonMssqlFile()
{
// Given a non-MSSQL document
@@ -127,13 +130,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
verify: (edits =>
{
// Then expect a single edit to be returned and for it to match the standard formatting
- Assert.Equal(0, edits.Length);
+ Assert.AreEqual(0, edits.Length);
LanguageServiceMock.Verify(x => x.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri), Times.Once);
}));
}
- [Fact]
+ [Test]
public async Task FormatDocumentTelemetryShouldIncludeFormatTypeProperty()
{
await RunAndVerifyTelemetryTest(
@@ -145,12 +148,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
// Then expect a telemetry event to have been sent with the right format definition
Assert.NotNull(actualParams);
- Assert.Equal(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
- Assert.Equal(TelemetryPropertyNames.DocumentFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);
+ Assert.AreEqual(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
+ Assert.AreEqual(TelemetryPropertyNames.DocumentFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);
});
}
- [Fact]
+ [Test]
public async Task FormatRangeTelemetryShouldIncludeFormatTypeProperty()
{
await RunAndVerifyTelemetryTest(
@@ -162,11 +165,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
{
// Then expect a telemetry event to have been sent with the right format definition
Assert.NotNull(actualParams);
- Assert.Equal(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
- Assert.Equal(TelemetryPropertyNames.RangeFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);
+ Assert.AreEqual(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
+ Assert.AreEqual(TelemetryPropertyNames.RangeFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);
// And expect range to have been correctly formatted
- Assert.Equal(1, result.Length);
+ Assert.AreEqual(1, result.Length);
AssertFormattingEqual(formattedSqlContents, result[0].NewText);
});
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageExtensibility/ExternalLanguageOperationTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageExtensibility/ExternalLanguageOperationTests.cs
index 7ed06c18..a1fb7068 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageExtensibility/ExternalLanguageOperationTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageExtensibility/ExternalLanguageOperationTests.cs
@@ -5,13 +5,13 @@ using Moq;
using System;
using System.Collections.Generic;
using System.Data;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
{
public class ExternalLanguageOperationTests
{
- [Fact]
+ [Test]
public void VerifyDeleteLanguageWithInvalidName()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
});
}
- [Fact]
+ [Test]
public void VerifyDeleteLanguage()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
@@ -39,7 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
});
}
- [Fact]
+ [Test]
public void VerifyCreateLanguage()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
@@ -63,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
});
}
- [Fact]
+ [Test]
public void VerifyCreateLanguageWithLocalFile()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
@@ -90,7 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
}
}
- [Fact]
+ [Test]
public void VerifyUpdateLanguage()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
@@ -130,7 +130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
});
}
- [Fact]
+ [Test]
public void VerifyUpdateContentLanguage()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
@@ -168,7 +168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageExtensibility
});
}
- [Fact]
+ [Test]
public void VerifyRemoveContentLanguage()
{
ExternalLanguageOperations operations = new ExternalLanguageOperations();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/AutocompleteTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/AutocompleteTests.cs
index f8102e4e..d724a525 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/AutocompleteTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/AutocompleteTests.cs
@@ -10,7 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Location = Microsoft.SqlTools.ServiceLayer.Workspace.Contracts.Location;
@@ -22,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
public class AutocompleteTests : LanguageServiceTestBase
{
- [Fact]
+ [Test]
public void HandleCompletionRequestDisabled()
{
InitializeTestObjects();
@@ -30,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.NotNull(langService.HandleCompletionRequest(null, null));
}
- [Fact]
+ [Test]
public void HandleCompletionResolveRequestDisabled()
{
InitializeTestObjects();
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.NotNull(langService.HandleCompletionResolveRequest(null, null));
}
- [Fact]
+ [Test]
public void HandleSignatureHelpRequestDisabled()
{
InitializeTestObjects();
@@ -46,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.NotNull(langService.HandleSignatureHelpRequest(null, null));
}
- [Fact]
+ [Test]
public async Task HandleSignatureHelpRequestNonMssqlFile()
{
InitializeTestObjects();
@@ -75,7 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
signatureRequestContext.Verify(m => m.SendError(It.IsAny(), It.IsAny()), Times.Never());
}
- [Fact]
+ [Test]
public void AddOrUpdateScriptParseInfoNullUri()
{
InitializeTestObjects();
@@ -83,8 +83,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.True(langService.ScriptParseInfoMap.ContainsKey("abracadabra"));
}
- [Fact]
- public async void HandleDefinitionRequest_InvalidTextDocument_SendsEmptyListResponse()
+ [Test]
+ public async Task HandleDefinitionRequest_InvalidTextDocument_SendsEmptyListResponse()
{
InitializeTestObjects();
textDocument.TextDocument.Uri = "invaliduri";
@@ -104,22 +104,22 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.True(result.Length == 0, $"Unexpected values passed to SendResult : [{ string.Join(",", (object[])result)}]");
}
- [Fact]
+ [Test]
public void RemoveScriptParseInfoNullUri()
{
InitializeTestObjects();
Assert.False(langService.RemoveScriptParseInfo("abc123"));
}
- [Fact]
+ [Test]
public void IsPreviewWindowNullScriptFileTest()
{
InitializeTestObjects();
Assert.False(langService.IsPreviewWindow(null));
}
- [Fact]
- public async void HandleCompletionRequest_InvalidTextDocument_SendsNullResult()
+ [Test]
+ public async Task HandleCompletionRequest_InvalidTextDocument_SendsNullResult()
{
InitializeTestObjects();
// setup the mock for SendResult to capture the items
@@ -136,7 +136,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.Null(completionItems);
}
- [Fact]
+ [Test]
public void GetDiagnosticFromMarkerTest()
{
var scriptFileMarker = new ScriptFileMarker()
@@ -155,26 +155,26 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
}
};
var diagnostic = DiagnosticsHelper.GetDiagnosticFromMarker(scriptFileMarker);
- Assert.Equal(diagnostic.Message, scriptFileMarker.Message);
+ Assert.AreEqual(diagnostic.Message, scriptFileMarker.Message);
}
- [Fact]
+ [Test]
public void MapDiagnosticSeverityTest()
{
var level = ScriptFileMarkerLevel.Error;
- Assert.Equal(DiagnosticsHelper.MapDiagnosticSeverity(level), DiagnosticSeverity.Error);
+ Assert.AreEqual(DiagnosticSeverity.Error, DiagnosticsHelper.MapDiagnosticSeverity(level));
level = ScriptFileMarkerLevel.Warning;
- Assert.Equal(DiagnosticsHelper.MapDiagnosticSeverity(level), DiagnosticSeverity.Warning);
+ Assert.AreEqual(DiagnosticSeverity.Warning, DiagnosticsHelper.MapDiagnosticSeverity(level));
level = ScriptFileMarkerLevel.Information;
- Assert.Equal(DiagnosticsHelper.MapDiagnosticSeverity(level), DiagnosticSeverity.Information);
+ Assert.AreEqual(DiagnosticSeverity.Information, DiagnosticsHelper.MapDiagnosticSeverity(level));
level = (ScriptFileMarkerLevel)100;
- Assert.Equal(DiagnosticsHelper.MapDiagnosticSeverity(level), DiagnosticSeverity.Error);
+ Assert.AreEqual(DiagnosticSeverity.Error, DiagnosticsHelper.MapDiagnosticSeverity(level));
}
///
/// Tests the primary completion list event handler
///
- [Fact]
+ [Test]
public void GetCompletionsHandlerTest()
{
InitializeTestObjects();
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/BindingQueueTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/BindingQueueTests.cs
index 40f5c2a5..b1c20f4c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/BindingQueueTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/BindingQueueTests.cs
@@ -13,7 +13,7 @@ using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
using Microsoft.SqlServer.Management.SqlParser.Parser;
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
{
@@ -115,7 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
///
/// Queues a single task
///
- [Fact]
+ [Test]
public void QueueOneBindingOperationTest()
{
InitializeTestSettings();
@@ -129,15 +129,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
this.bindingQueue.StopQueueProcessor(15000);
- Assert.Equal(1, this.bindCallCount);
- Assert.Equal(0, this.timeoutCallCount);
+ Assert.AreEqual(1, this.bindCallCount);
+ Assert.AreEqual(0, this.timeoutCallCount);
Assert.False(this.isCancelationRequested);
}
///
/// Queues a single task
///
- [Fact]
+ [Test]
public void QueueWithUnhandledExceptionTest()
{
InitializeTestSettings();
@@ -158,14 +158,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
Assert.True(isExceptionHandled);
var result = queueItem.GetResultAsT();
- Assert.Equal(defaultReturnObject, result);
+ Assert.AreEqual(defaultReturnObject, result);
}
///
/// Queue a 100 short tasks
///
// Disable flaky test (mairvine - 3/15/2018)
- // [Fact]
+ // [Test]
public void Queue100BindingOperationTest()
{
InitializeTestSettings();
@@ -182,15 +182,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
this.bindingQueue.StopQueueProcessor(15000);
- Assert.Equal(100, this.bindCallCount);
- Assert.Equal(0, this.timeoutCallCount);
+ Assert.AreEqual(100, this.bindCallCount);
+ Assert.AreEqual(0, this.timeoutCallCount);
Assert.False(this.isCancelationRequested);
}
///
/// Queue an task with a long operation causing a timeout
///
- [Fact]
+ [Test]
public void QueueWithTimeout()
{
InitializeTestSettings();
@@ -207,8 +207,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
this.bindingQueue.StopQueueProcessor(15000);
- Assert.Equal(0, this.bindCallCount);
- Assert.Equal(1, this.timeoutCallCount);
+ Assert.AreEqual(0, this.bindCallCount);
+ Assert.AreEqual(1, this.timeoutCallCount);
Assert.True(this.isCancelationRequested);
}
@@ -216,7 +216,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
/// Queue a task with a long operation causing a timeout
/// and make sure subsequent tasks don't execute while task is completing
///
- [Fact]
+ [Test]
public void QueueWithTimeoutDoesNotRunNextTask()
{
string operationKey = "testkey";
@@ -261,7 +261,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
this.bindingQueue.StopQueueProcessor(15000);
- Assert.Equal(1, this.timeoutCallCount);
+ Assert.AreEqual(1, this.timeoutCallCount);
Assert.False(firstOperationCanceled);
Assert.False(secondOperationExecuted);
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/CompletionServiceTest.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/CompletionServiceTest.cs
index 02c5070d..fe137b73 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/CompletionServiceTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/CompletionServiceTest.cs
@@ -14,14 +14,14 @@ using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Moq;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
{
public class CompletionServiceTest
{
// Disable flaky test (mairvine - 3/15/2018)
- // [Fact]
+ // [Test]
public void CompletionItemsShouldCreatedUsingSqlParserIfTheProcessDoesNotTimeout()
{
ConnectedBindingQueue bindingQueue = new ConnectedBindingQueue();
@@ -40,10 +40,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
AutoCompletionResult result = completionService.CreateCompletions(connectionInfo, docInfo, useLowerCaseSuggestions);
Assert.NotNull(result);
- Assert.NotEqual(result.CompletionItems == null ? 0 : result.CompletionItems.Count(), defaultCompletionList.Count());
+ var count = result.CompletionItems == null ? 0 : result.CompletionItems.Count();
+
+ Assert.That(count, Is.Not.EqualTo(defaultCompletionList.Count()));
}
- [Fact]
+ [Test]
public void CompletionItemsShouldCreatedUsingDefaultListIfTheSqlParserProcessTimesout()
{
ConnectedBindingQueue bindingQueue = new ConnectedBindingQueue();
@@ -61,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
AutoCompletionResult result = completionService.CreateCompletions(connectionInfo, docInfo, useLowerCaseSuggestions);
Assert.NotNull(result);
- Assert.Equal(result.CompletionItems.Count(), defaultCompletionList.Count());
+ Assert.AreEqual(result.CompletionItems.Count(), defaultCompletionList.Count());
Thread.Sleep(3000);
Assert.True(connectionInfo.IntellisenseMetrics.Quantile.Any());
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/InteractionMetricsTest.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/InteractionMetricsTest.cs
index a71d27b4..ffc4fbc2 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/InteractionMetricsTest.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/LanguageServer/InteractionMetricsTest.cs
@@ -5,57 +5,57 @@
using System;
using System.Collections.Generic;
-using Xunit;
+using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
{
public class InteractionMetricsTest
{
- [Fact]
+ [Test]
public void MetricsShouldGetSortedGivenUnSortedArray()
{
int[] metrics = new int[] { 4, 8, 1, 11, 3 };
int[] expected = new int[] { 1, 3, 4, 8, 11 };
InteractionMetrics interactionMetrics = new InteractionMetrics(metrics);
- Assert.Equal(interactionMetrics.Metrics, expected);
+ Assert.AreEqual(interactionMetrics.Metrics, expected);
}
- [Fact]
+ [Test]
public void MetricsShouldThrowExceptionGivenNullInput()
{
int[] metrics = null;
Assert.Throws(() => new InteractionMetrics(metrics));
}
- [Fact]
+ [Test]
public void MetricsShouldThrowExceptionGivenEmptyInput()
{
int[] metrics = new int[] { };
Assert.Throws(() => new InteractionMetrics(metrics));
}
- [Fact]
+ [Test]
public void MetricsShouldNotChangeGivenSortedArray()
{
int[] metrics = new int[] { 1, 3, 4, 8, 11 };
int[] expected = new int[] { 1, 3, 4, 8, 11 };
InteractionMetrics interactionMetrics = new InteractionMetrics(metrics);
- Assert.Equal(interactionMetrics.Metrics, expected);
+ Assert.AreEqual(interactionMetrics.Metrics, expected);
}
- [Fact]
+ [Test]
public void MetricsShouldNotChangeGivenArrayWithOneItem()
{
int[] metrics = new int[] { 11 };
int[] expected = new int[] { 11 };
InteractionMetrics interactionMetrics = new InteractionMetrics