Convert most tools service tests to nunit (#1037)

* Remove xunit dependency from testdriver

* swap expected/actual as needed

* Convert Test.Common to nunit

* port hosting unit tests to nunit

* port batchparser integration tests to nunit

* port testdriver.tests to nunit

* fix target to copy dependency

* port servicelayer unittests to nunit

* more unit test fixes

* port integration tests to nunit

* fix test method type

* try using latest windows build for PRs

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

View File

@@ -16,13 +16,13 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
public class BatchTests
{
[Fact]
[Test]
public void BatchCreationTest()
{
// If I create a new batch...
@@ -30,32 +30,32 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... The text of the batch should be stored
Assert.NotEmpty(batch.BatchText);
Assert.That(batch.BatchText, Is.Not.Empty);
// ... It should not have executed and no error
Assert.False(batch.HasExecuted, "The query should not have executed.");
Assert.False(batch.HasError);
// ... The results should be empty
Assert.Empty(batch.ResultSets);
Assert.Empty(batch.ResultSummaries);
Assert.That(batch.ResultSets, Is.Empty);
Assert.That(batch.ResultSummaries, Is.Empty);
// ... The start line of the batch should be 0
Assert.Equal(0, batch.Selection.StartLine);
Assert.AreEqual(0, batch.Selection.StartLine);
// ... It's ordinal ID should be what I set it to
Assert.Equal(Common.Ordinal, batch.Id);
Assert.AreEqual(Common.Ordinal, batch.Id);
// ... The summary should have the same info
Assert.Equal(Common.Ordinal, batch.Summary.Id);
Assert.AreEqual(Common.Ordinal, batch.Summary.Id);
Assert.Null(batch.Summary.ResultSetSummaries);
Assert.Equal(0, batch.Summary.Selection.StartLine);
Assert.NotEqual(default(DateTime).ToString("o"), batch.Summary.ExecutionStart); // Should have been set at construction
Assert.AreEqual(0, batch.Summary.Selection.StartLine);
Assert.That(batch.Summary.ExecutionStart, Is.Not.EqualTo(default(DateTime).ToString("o"))); // Should have been set at construction
Assert.Null(batch.Summary.ExecutionEnd);
Assert.Null(batch.Summary.ExecutionElapsed);
}
[Fact]
[Test]
public async Task BatchExecuteNoResultSets()
{
// Setup:
@@ -77,9 +77,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.Equal(0, resultSetCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
Assert.AreEqual(0, resultSetCalls);
// ... The batch and the summary should be correctly assigned
ValidateBatch(batch, 0, false);
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ValidateMessages(batch, 1, messages);
}
[Fact]
[Test]
public async Task BatchExecuteOneResultSet()
{
// Setup:
@@ -113,9 +113,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.Equal(1, resultSetCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
Assert.AreEqual(1, resultSetCalls);
// ... There should be exactly one result set
ValidateBatch(batch, resultSets, false);
@@ -123,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ValidateMessages(batch, 1, messages);
}
[Fact]
[Test]
public async Task BatchExecuteTwoResultSets()
{
// Setup:
@@ -149,9 +149,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.Equal(2, resultSetCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
Assert.AreEqual(2, resultSetCalls);
// ... It should have executed without error
ValidateBatch(batch, resultSets, false);
@@ -159,7 +159,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ValidateMessages(batch, 1, messages);
}
[Fact]
[Test]
public async Task BatchExecuteMultiExecutions()
{
// Setup:
@@ -185,9 +185,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.Equal(2, resultSetCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
Assert.AreEqual(2, resultSetCalls);
// ... There should be exactly two result sets
ValidateBatch(batch, 2, false);
@@ -196,7 +196,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ValidateMessages(batch, 2, messages);
}
[Fact]
[Test]
public async Task BatchExecuteInvalidQuery()
{
// Setup:
@@ -218,23 +218,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
// ... It should have executed with error
ValidateBatch(batch, 0, true);
ValidateBatchSummary(batch);
// ... There should be one error message returned
Assert.Equal(1, messages.Count);
Assert.All(messages, m =>
{
Assert.True(m.IsError);
Assert.Equal(batch.Id, m.BatchId);
});
Assert.That(messages.Select(m => new { m.IsError, m.BatchId.Value }), Is.EqualTo(new[] { new { IsError = true, Value = batch.Id } }), "There should be one error message returned");
}
[Fact]
[Test]
public async Task BatchExecuteInvalidQueryMultiExecutions()
{
// Setup:
@@ -256,23 +250,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... Callbacks should have been called the appropriate number of times
Assert.Equal(1, batchStartCalls);
Assert.Equal(1, batchEndCalls);
Assert.AreEqual(1, batchStartCalls);
Assert.AreEqual(1, batchEndCalls);
// ... It should have executed with error
ValidateBatch(batch, 0, true);
ValidateBatchSummary(batch);
// ... There should be two error messages returned and 4 info messages (loop start/end, plus 2 for ignoring the error)
Assert.Equal(6, messages.Count);
Assert.All(messages, m =>
{
Assert.Equal(batch.Id, m.BatchId);
});
Assert.Equal(2, messages.Where(m => m.IsError).Count());
Assert.AreEqual(6, messages.Count);
Assert.That(messages.Select(m => m.BatchId), Is.EquivalentTo(new[] { batch.Id, batch.Id, batch.Id, batch.Id, batch.Id, batch.Id }));
Assert.That(messages.Select(m => m.IsError), Has.Exactly(2).True);
}
[Fact]
[Test]
public async Task BatchExecuteExecuted()
{
// Setup: Build a data set to return
@@ -296,7 +287,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
b => { throw new Exception("Batch completion callback should not have been called"); },
m => { throw new Exception("Message callback should not have been called"); },
null);
await Assert.ThrowsAsync<InvalidOperationException>(
Assert.ThrowsAsync<InvalidOperationException>(
() => batch.Execute(GetConnection(ci), CancellationToken.None));
// ... The data should still be available without error
@@ -304,10 +295,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ValidateBatchSummary(batch);
}
[Theory]
[InlineData("")]
[InlineData(null)]
public void BatchExecuteNoSql(string query)
[Test]
public void BatchExecuteNoSql([Values(null, "")] string query)
{
// If:
// ... I create a batch that has an empty query
@@ -316,7 +305,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.Throws<ArgumentException>(() => new Batch(query, Common.SubsectionDocument, Common.Ordinal, MemoryFileSystem.GetFileStreamFactory()));
}
[Fact]
[Test]
public void BatchNoBufferFactory()
{
// If:
@@ -326,7 +315,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.Throws<ArgumentNullException>(() => new Batch("stuff", Common.SubsectionDocument, Common.Ordinal, null));
}
[Fact]
[Test]
public void BatchInvalidOrdinal()
{
// If:
@@ -336,7 +325,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.Throws<ArgumentOutOfRangeException>(() => new Batch("stuff", Common.SubsectionDocument, -1, MemoryFileSystem.GetFileStreamFactory()));
}
[Fact]
[Test]
public void StatementCompletedHandlerTest()
{
// If:
@@ -357,7 +346,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.True(messageCalls == 2);
}
[Fact]
[Test]
public async Task ServerMessageHandlerShowsErrorMessages()
{
// Set up the batch to track message calls
@@ -384,14 +373,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
await batch.HandleSqlErrorMessage(1, 15, 0, 1, string.Empty, errorMessage);
// Then one error message call should be recorded
Assert.Equal(1, errorMessageCalls);
Assert.Equal(0, infoMessageCalls);
Assert.AreEqual(1, errorMessageCalls);
Assert.AreEqual(0, infoMessageCalls);
// And the actual message should be a formatted version of the error message
Assert.True(actualMessage.Length > errorMessage.Length);
}
[Fact]
[Test]
public async Task ServerMessageHandlerShowsInfoMessages()
{
// Set up the batch to track message calls
@@ -418,11 +407,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
await batch.HandleSqlErrorMessage(0, 0, 0, 1, string.Empty, infoMessage);
// Then one info message call should be recorded
Assert.Equal(0, errorMessageCalls);
Assert.Equal(1, infoMessageCalls);
Assert.AreEqual(0, errorMessageCalls);
Assert.AreEqual(1, infoMessageCalls);
// And the actual message should be the exact info message
Assert.Equal(infoMessage, actualMessage);
Assert.AreEqual(infoMessage, actualMessage);
}
private static DbConnection GetConnection(ConnectionInfo info)
@@ -441,15 +430,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.NotNull(batch.ResultSummaries);
// Make sure the number of result sets matches
Assert.Equal(expectedResultSets, batch.ResultSets.Count);
Assert.AreEqual(expectedResultSets, batch.ResultSets.Count);
for (int i = 0; i < expectedResultSets; i++)
{
Assert.Equal(i, batch.ResultSets[i].Id);
Assert.AreEqual(i, batch.ResultSets[i].Id);
}
Assert.Equal(expectedResultSets, batch.ResultSummaries.Length);
Assert.AreEqual(expectedResultSets, batch.ResultSummaries.Length);
// Make sure that the error state is set properly
Assert.Equal(isError, batch.HasError);
Assert.AreEqual(isError, batch.HasError);
}
private static void ValidateBatchSummary(Batch batch)
@@ -457,10 +446,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
BatchSummary batchSummary = batch.Summary;
Assert.NotNull(batchSummary);
Assert.Equal(batch.Id, batchSummary.Id);
Assert.Equal(batch.ResultSets.Count, batchSummary.ResultSetSummaries.Length);
Assert.Equal(batch.Selection, batchSummary.Selection);
Assert.Equal(batch.HasError, batchSummary.HasError);
Assert.AreEqual(batch.Id, batchSummary.Id);
Assert.AreEqual(batch.ResultSets.Count, batchSummary.ResultSetSummaries.Length);
Assert.AreEqual(batch.Selection, batchSummary.Selection);
Assert.AreEqual(batch.HasError, batchSummary.HasError);
// Something other than default date is provided for start and end times
Assert.True(DateTime.Parse(batchSummary.ExecutionStart) > default(DateTime));
@@ -472,15 +461,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
private static void ValidateMessages(Batch batch, int expectedMessages, IList<ResultMessage> messages)
{
// There should be equal number of messages to result sets
Assert.Equal(expectedMessages, messages.Count);
Assert.AreEqual(expectedMessages, messages.Count);
// No messages should be errors
// All messages must have the batch ID
Assert.All(messages, m =>
{
Assert.False(m.IsError);
Assert.Equal(batch.Id, m.BatchId);
});
Assert.That(messages.Select(m => new { m.IsError, m.BatchId.Value }), Has.All.EqualTo(new { IsError = false, Value = batch.Id }));
}
private static void BatchCallbackHelper(Batch batch, Action<Batch> startCallback, Action<Batch> endCallback,

View File

@@ -5,7 +5,7 @@
using System.Data.Common;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
@@ -55,7 +55,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
/// <summary>
/// Basic data type and properties test
/// </summary>
[Fact]
[Test]
public void DataTypeAndPropertiesTest()
{
// check default constructor doesn't throw
@@ -89,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
/// <summary>
/// constructor test
/// </summary>
[Fact]
[Test]
public void DbColumnConstructorTests()
{
// check that various constructor parameters initial the wrapper correctly

View File

@@ -12,14 +12,14 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
public class QueryTests
{
[Fact]
[Test]
public void QueryCreationCorrect()
{
// If:
@@ -30,12 +30,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... I should get back two batches to execute that haven't been executed
Assert.NotEmpty(query.QueryText);
Assert.That(query.QueryText, Is.Not.Empty);
Assert.False(query.HasExecuted);
Assert.Throws<InvalidOperationException>(() => query.BatchSummaries);
Assert.Throws<InvalidOperationException>(() => { var x = query.BatchSummaries; });
}
[Fact]
[Test]
public void QueryExecuteNoConnectionInfo()
{
// If:
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
Assert.Throws<ArgumentNullException>(() => new Query("Some Query", null, new QueryExecutionSettings(), MemoryFileSystem.GetFileStreamFactory()));
}
[Fact]
[Test]
public void QueryExecuteNoSettings()
{
// If:
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
new Query("Some query", Common.CreateTestConnectionInfo(null, false, false), null, MemoryFileSystem.GetFileStreamFactory()));
}
[Fact]
[Test]
public void QueryExecuteNoBufferFactory()
{
// If:
@@ -67,7 +67,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
new Query("Some query", Common.CreateTestConnectionInfo(null, false, false), new QueryExecutionSettings(), null));
}
[Fact]
[Test]
public void QueryExecuteSingleBatch()
{
// Setup:
@@ -92,21 +92,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... There should be exactly 1 batch
Assert.NotEmpty(query.Batches);
Assert.Equal(1, query.Batches.Length);
Assert.That(query.Batches, Is.Not.Empty);
Assert.AreEqual(1, query.Batches.Length);
// ... The query should have completed successfully with one batch summary returned
Assert.True(query.HasExecuted);
Assert.NotEmpty(query.BatchSummaries);
Assert.Equal(1, query.BatchSummaries.Length);
Assert.That(query.BatchSummaries, Is.Not.Empty);
Assert.AreEqual(1, query.BatchSummaries.Length);
// ... The batch callbacks should have been called precisely 1 time
Assert.Equal(1, batchStartCallbacksReceived);
Assert.Equal(1, batchCompleteCallbacksReceived);
Assert.Equal(1, batchMessageCallbacksReceived);
Assert.AreEqual(1, batchStartCallbacksReceived);
Assert.AreEqual(1, batchCompleteCallbacksReceived);
Assert.AreEqual(1, batchMessageCallbacksReceived);
}
[Fact]
[Test]
public async Task QueryExecuteSingleNoOpBatch()
{
// Setup: Keep track of all the messages received
@@ -129,16 +129,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... There should be no batches
Assert.Equal(1, query.Batches.Length);
Assert.AreEqual(1, query.Batches.Length);
// ... The query shouldn't have completed successfully
Assert.False(query.HasExecuted);
// ... The message callback should have been called 0 times
Assert.Equal(0, messages.Count);
Assert.AreEqual(0, messages.Count);
}
[Fact]
[Test]
public void QueryExecuteMultipleResultBatches()
{
// Setup:
@@ -165,21 +165,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... I should get back a query with one batch (no op batch is not included)
Assert.NotEmpty(query.Batches);
Assert.Equal(2, query.Batches.Length);
Assert.That(query.Batches, Is.Not.Empty);
Assert.AreEqual(2, query.Batches.Length);
// ... The query should have completed successfully with two batch summaries returned
Assert.True(query.HasExecuted);
Assert.NotEmpty(query.BatchSummaries);
Assert.Equal(2, query.BatchSummaries.Length);
Assert.That(query.BatchSummaries, Is.Not.Empty);
Assert.AreEqual(2, query.BatchSummaries.Length);
// ... The batch start, complete, and message callbacks should have been called precisely 2 times
Assert.Equal(2, batchStartCallbacksReceived);
Assert.Equal(2, batchCompletedCallbacksReceived);
Assert.Equal(2, batchMessageCallbacksReceived);
Assert.AreEqual(2, batchStartCallbacksReceived);
Assert.AreEqual(2, batchCompletedCallbacksReceived);
Assert.AreEqual(2, batchMessageCallbacksReceived);
}
[Fact]
[Test]
public async Task QueryExecuteMultipleBatchesWithNoOp()
{
// Setup:
@@ -205,19 +205,19 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... I should get back a query with two batches
Assert.NotEmpty(query.Batches);
Assert.Equal(2, query.Batches.Length);
Assert.That(query.Batches, Is.Not.Empty);
Assert.AreEqual(2, query.Batches.Length);
// ... The query should have completed successfully
Assert.True(query.HasExecuted);
// ... The batch callbacks should have been called 2 times (for each no op batch)
Assert.Equal(2, batchStartCallbacksReceived);
Assert.Equal(2, batchCompletionCallbacksReceived);
Assert.Equal(2, batchMessageCallbacksReceived);
Assert.AreEqual(2, batchStartCallbacksReceived);
Assert.AreEqual(2, batchCompletionCallbacksReceived);
Assert.AreEqual(2, batchMessageCallbacksReceived);
}
[Fact]
[Test]
public async Task QueryExecuteMultipleNoOpBatches()
{
// Setup:
@@ -241,16 +241,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... I should get back a query with no batches
Assert.Equal(2, query.Batches.Length);
Assert.AreEqual(2, query.Batches.Length);
// ... The query shouldn't have completed successfully
Assert.False(query.HasExecuted);
// ... The message callback should have been called exactly once
Assert.Equal(0, messages.Count);
Assert.AreEqual(0, messages.Count);
}
[Fact]
[Test]
public void QueryExecuteInvalidBatch()
{
// Setup:
@@ -277,18 +277,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... I should get back a query with one batch
Assert.NotEmpty(query.Batches);
Assert.Equal(1, query.Batches.Length);
Assert.That(query.Batches, Is.Not.Empty);
Assert.AreEqual(1, query.Batches.Length);
// ... There should be an error on the batch
Assert.True(query.HasExecuted);
Assert.NotEmpty(query.BatchSummaries);
Assert.Equal(1, query.BatchSummaries.Length);
Assert.That(query.BatchSummaries, Is.Not.Empty);
Assert.AreEqual(1, query.BatchSummaries.Length);
Assert.True(messages.Any(m => m.IsError));
// ... The batch callbacks should have been called once
Assert.Equal(1, batchStartCallbacksReceived);
Assert.Equal(1, batchCompletionCallbacksReceived);
Assert.AreEqual(1, batchStartCallbacksReceived);
Assert.AreEqual(1, batchCompletionCallbacksReceived);
}
private static void BatchCallbackHelper(Query q, Action<Batch> startCallback, Action<Batch> endCallback,

View File

@@ -17,13 +17,13 @@ using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Microsoft.SqlTools.Utility;
using Xunit;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
public class ResultSetTests
{
[Fact]
[Test]
public void ResultCreation()
{
// If:
@@ -33,32 +33,32 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... There should not be any data read yet
Assert.Null(resultSet.Columns);
Assert.Equal(0, resultSet.RowCount);
Assert.Equal(Common.Ordinal, resultSet.Id);
Assert.AreEqual(0, resultSet.RowCount);
Assert.AreEqual(Common.Ordinal, resultSet.Id);
// ... The summary should include the same info
Assert.Null(resultSet.Summary.ColumnInfo);
Assert.Equal(0, resultSet.Summary.RowCount);
Assert.Equal(Common.Ordinal, resultSet.Summary.Id);
Assert.Equal(Common.Ordinal, resultSet.Summary.BatchId);
Assert.AreEqual(0, resultSet.Summary.RowCount);
Assert.AreEqual(Common.Ordinal, resultSet.Summary.Id);
Assert.AreEqual(Common.Ordinal, resultSet.Summary.BatchId);
}
[Fact]
[Test]
public async Task ReadToEndNullReader()
{
// If: I create a new result set with a null db data reader
// Then: I should get an exception
var fsf = MemoryFileSystem.GetFileStreamFactory();
ResultSet resultSet = new ResultSet(Common.Ordinal, Common.Ordinal, fsf);
await Assert.ThrowsAsync<ArgumentNullException>(() => resultSet.ReadResultToEnd(null, CancellationToken.None));
Assert.ThrowsAsync<ArgumentNullException>(() => resultSet.ReadResultToEnd(null, CancellationToken.None));
}
/// <summary>
/// Read to End test
/// </summary>
/// <param name="testDataSet"></param>
[Theory]
[MemberData(nameof(ReadToEndSuccessData), parameters: 6)]
[Test]
[TestCaseSource(nameof(ReadToEndSuccessData))]
public async Task ReadToEndSuccess(TestResultSet[] testDataSet)
{
// Setup: Create a results Available callback for result set
@@ -113,13 +113,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// ... The columns should be set
// ... There should be rows to read back
Assert.NotNull(resultSet.Columns);
Assert.Equal(Common.StandardColumns, resultSet.Columns.Length);
Assert.Equal(testDataSet[0].Rows.Count, resultSet.RowCount);
Assert.AreEqual(Common.StandardColumns, resultSet.Columns.Length);
Assert.AreEqual(testDataSet[0].Rows.Count, resultSet.RowCount);
// ... The summary should have the same info
Assert.NotNull(resultSet.Summary.ColumnInfo);
Assert.Equal(Common.StandardColumns, resultSet.Summary.ColumnInfo.Length);
Assert.Equal(testDataSet[0].Rows.Count, resultSet.Summary.RowCount);
Assert.AreEqual(Common.StandardColumns, resultSet.Summary.ColumnInfo.Length);
Assert.AreEqual(testDataSet[0].Rows.Count, resultSet.Summary.RowCount);
// and:
//
@@ -130,11 +130,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
/// Read to End test
/// </summary>
/// <param name="testDataSet"></param>
[Theory]
[MemberData(nameof(ReadToEndSuccessData), parameters: 3)]
[Test]
[TestCaseSource(nameof(ReadToEndSuccessDataParallel))]
public async Task ReadToEndSuccessSeveralTimes(TestResultSet[] testDataSet)
{
const int NumberOfInvocations = 5000;
const int NumberOfInvocations = 50;
List<Task> allTasks = new List<Task>();
Parallel.ForEach(Partitioner.Create(0, NumberOfInvocations), (range) =>
{
@@ -149,21 +149,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
await Task.WhenAll(allTasks);
}
public static IEnumerable<object[]> ReadToEndSuccessData(int numTests) => Common.TestResultSetsEnumeration.Select(r => new object[] { new TestResultSet[] { r } }).Take(numTests);
public static readonly IEnumerable<object[]> ReadToEndSuccessData = Common.TestResultSetsEnumeration.Select(r => new object[] { new TestResultSet[] { r } }).Take(6);
// using all 6 sets with the parallel test can raise an OutOfMemoryException
public static readonly IEnumerable<object[]> ReadToEndSuccessDataParallel = Common.TestResultSetsEnumeration.Select(r => new object[] { new TestResultSet[] { r } }).Take(3);
[Theory]
[MemberData(nameof(CallMethodWithoutReadingData))]
[Test]
[TestCaseSource(nameof(CallMethodWithoutReadingData))]
public void CallMethodWithoutReading(Action<ResultSet> testMethod)
{
// Setup: Create a new result set with valid db data reader
var fileStreamFactory = MemoryFileSystem.GetFileStreamFactory();
ResultSet resultSet = new ResultSet(Common.Ordinal, Common.Ordinal, fileStreamFactory);
// If:
// ... I have a result set that has not been read
// ... and I attempt to call a method on it
// Then: It should throw an exception
Assert.ThrowsAny<Exception>(() => testMethod(resultSet));
Assert.That(() => testMethod(resultSet), Throws.InstanceOf<Exception>(), "I have a result set that has not been read. I attempt to call a method on it. It should throw an exception");
}
public static IEnumerable<object[]> CallMethodWithoutReadingData
@@ -239,10 +236,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
/// </summary>
/// <param name="forType"></param>
/// <returns></returns>
[Theory]
[InlineData("JSON")]
[InlineData("XML")]
public async Task ReadToEndForXmlJson(string forType)
[Test]
public async Task ReadToEndForXmlJson([Values("JSON", "XML")] string forType)
{
// Setup:
// ... Build a FOR XML or FOR JSON data set
@@ -306,8 +301,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// ... There should only be one column
// ... There should only be one row
//
Assert.Equal(1, resultSet.Columns.Length);
Assert.Equal(1, resultSet.RowCount);
Assert.AreEqual(1, resultSet.Columns.Length);
Assert.AreEqual(1, resultSet.RowCount);
// and:
@@ -322,14 +317,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var task = resultSet.GetSubset(0, 10);
task.Wait();
var subset = task.Result;
Assert.Equal(1, subset.RowCount);
Assert.AreEqual(1, subset.RowCount);
}
[Theory]
[InlineData(-1, 0)] // Too small start row
[InlineData(20, 0)] // Too large start row
[InlineData(0, -1)] // Negative row count
public async Task GetSubsetInvalidParameters(int startRow, int rowCount)
[Test, Sequential]
public async Task GetSubsetInvalidParameters([Values(-1,20,0)] int startRow,
[Values(0,0,-1)] int rowCount)
{
// If:
// ... I create a new result set with a valid db data reader
@@ -342,15 +335,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// ... And attempt to get a subset with invalid parameters
// Then:
// ... It should throw an exception for an invalid parameter
await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => resultSet.GetSubset(startRow, rowCount));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => resultSet.GetSubset(startRow, rowCount));
}
[Theory]
[InlineData(0, 3)] // Standard scenario, 3 rows should come back
[InlineData(0, 20)] // Asking for too many rows, 5 rows should come back
[InlineData(1, 3)] // Asking for proper subset of rows from non-zero start
[InlineData(1, 20)] // Asking for too many rows at a non-zero start
public async Task GetSubsetSuccess(int startRow, int rowCount)
[Test]
public async Task GetSubsetSuccess([Values(0,1)]int startRow,
[Values(3,20)] int rowCount)
{
// If:
// ... I create a new result set with a valid db data reader
@@ -365,20 +355,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... rows sub-array and RowCount field of the subset should match
Assert.Equal(subset.RowCount, subset.Rows.Length);
Assert.AreEqual(subset.RowCount, subset.Rows.Length);
// Then:
// ... There should be rows in the subset, either the number of rows or the number of
// rows requested or the number of rows in the result set, whichever is lower
long availableRowsFromStart = resultSet.RowCount - startRow;
Assert.Equal(Math.Min(availableRowsFromStart, rowCount), subset.RowCount);
Assert.AreEqual(Math.Min(availableRowsFromStart, rowCount), subset.RowCount);
// ... The rows should have the same number of columns as the resultset
Assert.Equal(resultSet.Columns.Length, subset.Rows[0].Length);
Assert.AreEqual(resultSet.Columns.Length, subset.Rows[0].Length);
}
[Theory]
[MemberData(nameof(RowInvalidParameterData))]
[Test]
[TestCaseSource(nameof(RowInvalidParameterData))]
public async Task RowInvalidParameter(Action<ResultSet> actionToPerform)
{
// If: I create a new result set and execute it
@@ -387,8 +377,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
ResultSet resultSet = new ResultSet(Common.Ordinal, Common.Ordinal, fileStreamFactory);
await resultSet.ReadResultToEnd(mockReader, CancellationToken.None);
// Then: Attempting to read an invalid row should fail
Assert.ThrowsAny<Exception>(() => actionToPerform(resultSet));
Assert.That(() => actionToPerform(resultSet), Throws.InstanceOf<Exception>(), "Attempting to read an invalid row should fail");
}
public static IEnumerable<object[]> RowInvalidParameterData
@@ -413,7 +402,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
}
}
[Fact]
[Test]
public async Task RemoveRowSuccess()
{
// Setup: Create a result set that has the standard data set on it
@@ -428,11 +417,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... The row count should decrease
// ... The last row should have moved up by 1
Assert.Equal(Common.StandardRows - 1, resultSet.RowCount);
Assert.AreEqual(Common.StandardRows - 1, resultSet.RowCount);
Assert.Throws<ArgumentOutOfRangeException>(() => resultSet.GetRow(Common.StandardRows - 1));
}
[Fact]
[Test]
public async Task AddRowNoRows()
{
// Setup:
@@ -448,13 +437,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I add a row with a reader that has no rows
// Then:
// ... I should get an exception
await Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.AddRow(emptyReader));
Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.AddRow(emptyReader));
// ... The row count should not have changed
Assert.Equal(Common.StandardRows, resultSet.RowCount);
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
}
[Fact]
[Test]
public async Task AddRowThrowsOnRead()
{
// Setup:
@@ -467,16 +456,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// ... Create a mock reader that will throw on read
var throwingReader = GetReader(new[] {new TestResultSet(5, 0)}, true, Constants.StandardQuery);
// If: I add a row with a reader that throws on read
// Then:
// ... I should get an exception
await Assert.ThrowsAnyAsync<DbException>(() => resultSet.AddRow(throwingReader));
// ... The row count should not have changed
Assert.Equal(Common.StandardRows, resultSet.RowCount);
Assert.ThrowsAsync<TestDbException>(() => resultSet.AddRow(throwingReader), "I add a row with a reader that throws on read. I should get an exception");
// ... The row count should not have changed
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
}
[Fact]
[Test]
public async Task AddRowSuccess()
{
// Setup:
@@ -497,13 +483,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... There should be a new row in the list of rows
Assert.Equal(Common.StandardRows + 1, resultSet.RowCount);
Assert.AreEqual(Common.StandardRows + 1, resultSet.RowCount);
// ... The new row should be readable and all cells contain the test value
Assert.All(resultSet.GetRow(Common.StandardRows), cell => Assert.Equal("QQQ", cell.RawObject));
Assert.That(resultSet.GetRow(Common.StandardRows).Select(r => r.RawObject), Has.All.EqualTo("QQQ"), "The new row should be readable and all cells contain the test value");
}
[Fact]
[Test]
public async Task UpdateRowNoRows()
{
// Setup:
@@ -519,13 +504,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I add a row with a reader that has no rows
// Then:
// ... I should get an exception
await Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.UpdateRow(0, emptyReader));
Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.UpdateRow(0, emptyReader));
// ... The row count should not have changed
Assert.Equal(Common.StandardRows, resultSet.RowCount);
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
}
[Fact]
[Test]
public async Task UpdateRowSuccess()
{
// Setup:
@@ -546,10 +531,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// Then:
// ... There should be the same number of rows
Assert.Equal(Common.StandardRows, resultSet.RowCount);
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
// ... The new row should be readable and all cells contain the test value
Assert.All(resultSet.GetRow(0), cell => Assert.Equal("QQQ", cell.RawObject));
Assert.That(resultSet.GetRow(0).Select(c => c.RawObject), Has.All.EqualTo("QQQ"), "The new row should be readable and all cells contain the test value");
}
private static DbDataReader GetReader(TestResultSet[] dataSet, bool throwOnRead, string query)

View File

@@ -20,8 +20,6 @@ using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Workspace;
using Moq;
using NUnit.Framework;
using Xunit;
using Assert = Xunit.Assert;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
@@ -30,7 +28,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
#region Get SQL Tests
[Fact]
[Test]
public void ExecuteDocumentStatementTest()
{
string query = string.Format("{0}{1}GO{1}{0}", Constants.StandardQuery, Environment.NewLine);
@@ -41,10 +39,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var queryText = queryService.GetSqlText(queryParams);
// The text should match the standard query
Assert.Equal(queryText, Constants.StandardQuery);
Assert.AreEqual(queryText, Constants.StandardQuery);
}
[Fact]
[Test]
public void ExecuteDocumentStatementSameLine()
{
var statement1 = Constants.StandardQuery;
@@ -72,10 +70,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var queryText = queryService.GetSqlText(queryParams);
// The query text should match the expected statement at the cursor
Assert.Equal(expectedQueryText, queryText);
Assert.AreEqual(expectedQueryText, queryText);
}
[Fact]
[Test]
public void GetSqlTextFromDocumentRequestFull()
{
// Setup:
@@ -91,10 +89,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should match the constructed query
Assert.Equal(query, queryText);
Assert.AreEqual(query, queryText);
}
[Fact]
[Test]
public void GetSqlTextFromDocumentRequestPartial()
{
// Setup:
@@ -107,11 +105,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Constants.OwnerUri, QuerySelection = Common.SubsectionDocument };
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should be a subset of the constructed query
Assert.Contains(queryText, query);
Assert.That(query, Does.Contain(queryText), "The text should be a subset of the constructed query");
}
[Fact]
[Test]
public void GetSqlTextFromStringRequest()
{
// Setup:
@@ -124,10 +121,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
var queryText = queryService.GetSqlText(queryParams);
// Then: The text should match the standard query
Assert.Equal(Constants.StandardQuery, queryText);
Assert.AreEqual(Constants.StandardQuery, queryText);
}
[Fact]
[Test]
public void GetSqlTextFromInvalidType()
{
// Setup:
@@ -146,7 +143,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
#region Inter-Service API Tests
[Fact]
[Test]
public async Task InterServiceExecuteNullExecuteParams()
{
// Setup: Create a query service
@@ -156,11 +153,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I call the inter-service API to execute with a null execute params
// Then: It should throw
await Assert.ThrowsAsync<ArgumentNullException>(
Assert.ThrowsAsync<ArgumentNullException>(
() => qes.InterServiceExecuteQuery(null, null, eventSender, null, null, null, null));
}
[Fact]
[Test]
public async Task InterServiceExecuteNullEventSender()
{
// Setup: Create a query service, and execute params
@@ -169,11 +166,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I call the inter-service API to execute a query with a a null event sender
// Then: It should throw
await Assert.ThrowsAsync<ArgumentNullException>(
Assert.ThrowsAsync<ArgumentNullException>(
() => qes.InterServiceExecuteQuery(executeParams, null, null, null, null, null, null));
}
[Fact]
[Test]
public async Task InterServiceDisposeNullSuccessFunc()
{
// Setup: Create a query service and dispose params
@@ -182,11 +179,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I call the inter-service API to dispose a query with a null success function
// Then: It should throw
await Assert.ThrowsAsync<ArgumentNullException>(
Assert.ThrowsAsync<ArgumentNullException>(
() => qes.InterServiceDisposeQuery(Constants.OwnerUri, null, failureFunc));
}
[Fact]
[Test]
public async Task InterServiceDisposeNullFailureFunc()
{
// Setup: Create a query service and dispose params
@@ -195,7 +192,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// If: I call the inter-service API to dispose a query with a null success function
// Then: It should throw
await Assert.ThrowsAsync<ArgumentNullException>(
Assert.ThrowsAsync<ArgumentNullException>(
() => qes.InterServiceDisposeQuery(Constants.OwnerUri, successFunc, null));
}
@@ -205,8 +202,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
// NOTE: In order to limit test duplication, we're running the ExecuteDocumentSelection
// version of execute query. The code paths are almost identical.
[Fact]
private async Task QueryExecuteAllBatchesNoOp()
[Test]
public async Task QueryExecuteAllBatchesNoOp()
{
// If:
// ... I request to execute a valid query with all batches as no op
@@ -225,10 +222,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
.AddEventValidation(QueryCompleteEvent.Type, p =>
{
// Validate OwnerURI matches
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummaries);
Assert.Equal(2, p.BatchSummaries.Length);
Assert.All(p.BatchSummaries, bs => Assert.Equal(0, bs.ResultSetSummaries.Length));
Assert.AreEqual(2, p.BatchSummaries.Length);
Assert.That(p.BatchSummaries.Select(s => s.ResultSetSummaries.Length), Has.All.EqualTo(0));
}).Complete();
await Common.AwaitExecution(queryService, queryParams, efv.Object);
@@ -237,10 +234,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task QueryExecuteSingleBatchNoResultsTest()
{
// If:
@@ -264,13 +261,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
public static IEnumerable<object[]> TestResultSetsData(int numTests) => Common.TestResultSetsEnumeration.Select(r => new object[] { r }).Take(numTests);
private static readonly IEnumerable<object[]> TestResultSetsData = Common.TestResultSetsEnumeration.Select(r => new object[] { r }).Take(5);
[Xunit.Theory]
[MemberData(nameof(TestResultSetsData), parameters: 5)]
[Test]
[TestCaseSource(nameof(TestResultSetsData))]
public async Task QueryExecuteSingleBatchSingleResultTest(TestResultSet testResultSet)
{
// If:
@@ -298,11 +295,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.ValidateResultSetSummaries(collectedResultSetEventParams).Validate();
// ... There should be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Xunit.Theory]
[MemberData(nameof(TestResultSetsData), parameters: 4)]
[Test]
[TestCaseSource(nameof(TestResultSetsData))]
public async Task QueryExecuteSingleBatchMultipleResultTest(TestResultSet testResultSet)
{
// If:
@@ -329,10 +326,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.ValidateResultSetSummaries(collectedResultSetEventParams).Validate();
// ... There should be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task QueryExecuteMultipleBatchSingleResultTest()
{
// If:
@@ -362,10 +359,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.ValidateResultSetSummaries(collectedResultSetEventParams).Validate();
// ... There should be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task QueryExecuteUnconnectedUriTest()
{
// Given:
@@ -385,10 +382,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should be no active queries
Assert.Empty(queryService.ActiveQueries);
Assert.That(queryService.ActiveQueries, Is.Empty);
}
[Fact]
[Test]
public async Task QueryExecuteInProgressTest()
{
// If:
@@ -413,10 +410,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should only be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task QueryExecuteCompletedTest()
{
// If:
@@ -445,10 +442,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should only be one active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task QueryExecuteInvalidQueryTest()
{
// If:
@@ -471,11 +468,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
// ... There should not be an active query
Assert.Equal(1, queryService.ActiveQueries.Count);
Assert.AreEqual(1, queryService.ActiveQueries.Count);
}
// TODO https://github.com/Microsoft/vscode-mssql/issues/1003 reenable and make non-flaky
// [Fact]
// [Test]
public async Task SimpleExecuteErrorWithNoResultsTest()
{
var queryService = Common.GetPrimedExecutionService(null, true, false, false, null);
@@ -493,12 +490,12 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
Assert.Equal(0, queryService.ActiveQueries.Count);
Assert.AreEqual(0, queryService.ActiveQueries.Count);
}
// TODO reenable and make non-flaky
// [Fact]
// [Test]
public async Task SimpleExecuteVerifyResultsTest()
{
var queryService = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, false, null);
@@ -519,10 +516,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv.Validate();
Assert.Equal(0, queryService.ActiveQueries.Count);
Assert.AreEqual(0, queryService.ActiveQueries.Count);
}
[Fact]
[Test]
public async Task SimpleExecuteMultipleQueriesTest()
{
var queryService = Common.GetPrimedExecutionService(Common.StandardTestDataSet, true, false, false, null);
@@ -548,7 +545,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
efv1.Validate();
efv2.Validate();
Assert.Equal(0, queryService.ActiveQueries.Count);
Assert.AreEqual(0, queryService.ActiveQueries.Count);
}
#endregion
@@ -569,7 +566,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
return efv.AddResultValidation(p =>
{
Assert.Equal(p.RowCount, testData[0].Rows.Count);
Assert.AreEqual(p.RowCount, testData[0].Rows.Count);
});
}
@@ -578,7 +575,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
return efv.AddSimpleErrorValidation((m, e) =>
{
Assert.Equal(m, expectedMessage);
Assert.AreEqual(m, expectedMessage);
});
}
@@ -595,7 +592,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
return efv.AddEventValidation(BatchStartEvent.Type, p =>
{
// Validate OwnerURI and batch summary is returned
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummary);
});
}
@@ -606,7 +603,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
return efv.AddEventValidation(BatchCompleteEvent.Type, p =>
{
// Validate OwnerURI and result summary are returned
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummary);
});
}
@@ -617,7 +614,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
return efv.AddEventValidation(MessageEvent.Type, p =>
{
// Validate OwnerURI and message are returned
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.Message);
});
}
@@ -628,7 +625,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
return efv.SetupCallbackOnMethodSendEvent(expectedEvent, (p) =>
{
// Validate OwnerURI and summary are returned
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.ResultSetSummary);
resultSetEventParamList?.Add(p);
});
@@ -768,9 +765,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
{
return efv.AddEventValidation(QueryCompleteEvent.Type, p =>
{
Assert.Equal(Constants.OwnerUri, p.OwnerUri);
Assert.AreEqual(Constants.OwnerUri, p.OwnerUri);
Assert.NotNull(p.BatchSummaries);
Assert.Equal(expectedBatches, p.BatchSummaries.Length);
Assert.AreEqual(expectedBatches, p.BatchSummaries.Length);
});
}
}