mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 09:35:38 -05:00
Convert Async to sync (SqlClient apis) and cleanup async usage (#2167)
This commit is contained in:
@@ -120,9 +120,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
Query query = new Query(Constants.StandardQuery, ci, querySettings, MemoryFileSystem.GetFileStreamFactory());
|
||||
|
||||
string errorMessage = null;
|
||||
Query.QueryAsyncErrorEventHandler failureCallback = async (q, e) =>
|
||||
{
|
||||
Query.QueryAsyncErrorEventHandler failureCallback = (q, e) => {
|
||||
errorMessage = "Error Occured";
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
query.QueryFailed += failureCallback;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadToEndNullReader()
|
||||
public void ReadToEndNullReader()
|
||||
{
|
||||
// If: I create a new result set with a null db data reader
|
||||
// Then: I should get an exception
|
||||
@@ -169,8 +169,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
get
|
||||
{
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.GetSubset(0, 0).Wait())};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.UpdateRow(0, null).Wait())};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.AddRow(null).Wait())};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.UpdateRow(0, null))};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.AddRow(null))};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.RemoveRow(0))};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.GetRow(0))};
|
||||
yield return new object[] {new Action<ResultSet>(rs => rs.GetExecutionPlan().Wait())};
|
||||
@@ -399,7 +399,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
{
|
||||
yield return (rs, id) => rs.RemoveRow(id);
|
||||
yield return (rs, id) => rs.GetRow(id);
|
||||
yield return (rs, id) => rs.UpdateRow(id, null).Wait();
|
||||
yield return (rs, id) => rs.UpdateRow(id, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ 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
|
||||
Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.AddRow(emptyReader));
|
||||
Assert.Throws<InvalidOperationException>(() => resultSet.AddRow(emptyReader));
|
||||
|
||||
// ... The row count should not have changed
|
||||
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
|
||||
@@ -457,7 +457,7 @@ 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);
|
||||
|
||||
Assert.ThrowsAsync<TestDbException>(() => resultSet.AddRow(throwingReader), "I add a row with a reader that throws on read. I should get an exception");
|
||||
Assert.Throws<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);
|
||||
@@ -480,7 +480,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
var newRowReader = GetReader(results, false, Constants.StandardQuery);
|
||||
|
||||
// If: I add a new row to the result set
|
||||
await resultSet.AddRow(newRowReader);
|
||||
resultSet.AddRow(newRowReader);
|
||||
|
||||
// Then:
|
||||
// ... There should be a new row in the list of rows
|
||||
@@ -505,7 +505,7 @@ 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
|
||||
Assert.ThrowsAsync<InvalidOperationException>(() => resultSet.UpdateRow(0, emptyReader));
|
||||
Assert.Throws<InvalidOperationException>(() => resultSet.UpdateRow(0, emptyReader));
|
||||
|
||||
// ... The row count should not have changed
|
||||
Assert.AreEqual(Common.StandardRows, resultSet.RowCount);
|
||||
@@ -528,7 +528,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
var newRowReader = GetReader(results, false, Constants.StandardQuery);
|
||||
|
||||
// If: I add a new row to the result set
|
||||
await resultSet.UpdateRow(0, newRowReader);
|
||||
resultSet.UpdateRow(0, newRowReader);
|
||||
|
||||
// Then:
|
||||
// ... There should be the same number of rows
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
#region Inter-Service API Tests
|
||||
|
||||
[Test]
|
||||
public async Task InterServiceExecuteNullExecuteParams()
|
||||
public void InterServiceExecuteNullExecuteParams()
|
||||
{
|
||||
// Setup: Create a query service
|
||||
var qes = new QueryExecutionService(null, null);
|
||||
@@ -162,7 +162,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task InterServiceExecuteNullEventSender()
|
||||
public void InterServiceExecuteNullEventSender()
|
||||
{
|
||||
// Setup: Create a query service, and execute params
|
||||
var qes = new QueryExecutionService(null, null);
|
||||
@@ -175,7 +175,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task InterServiceDisposeNullSuccessFunc()
|
||||
public void InterServiceDisposeNullSuccessFunc()
|
||||
{
|
||||
// Setup: Create a query service and dispose params
|
||||
var qes = new QueryExecutionService(null, null);
|
||||
@@ -188,7 +188,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task InterServiceDisposeNullFailureFunc()
|
||||
public void InterServiceDisposeNullFailureFunc()
|
||||
{
|
||||
// Setup: Create a query service and dispose params
|
||||
var qes = new QueryExecutionService(null, null);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ExecutionPlanInvalid()
|
||||
public void ExecutionPlanInvalid()
|
||||
{
|
||||
// Setup:
|
||||
// ... I have a batch that has been executed
|
||||
@@ -71,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BatchExecutionPlanInvalidTest()
|
||||
public void BatchExecutionPlanInvalidTest()
|
||||
{
|
||||
// Setup:
|
||||
// ... I have a batch that has been executed without an execution plan
|
||||
@@ -83,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BatchExecutionPlanInvalidParamsTest([Values(-1,2)] int resultSetIndex)
|
||||
public void BatchExecutionPlanInvalidParamsTest([Values(-1,2)] int resultSetIndex)
|
||||
{
|
||||
// If I have an executed batch which has an execution plan
|
||||
Batch b = Common.GetExecutedBatchWithExecutionPlan();
|
||||
@@ -99,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
#region Query Class Tests
|
||||
|
||||
[Test]
|
||||
public async Task QueryExecutionPlanInvalidParamsTest([Values(-1,2)]int batchIndex)
|
||||
public void QueryExecutionPlanInvalidParamsTest([Values(-1,2)]int batchIndex)
|
||||
{
|
||||
// Setup query settings
|
||||
QueryExecutionSettings querySettings = new QueryExecutionSettings
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SubsetServiceMissingQueryTest()
|
||||
public void SubsetServiceMissingQueryTest()
|
||||
{
|
||||
// If:
|
||||
// ... I ask for a set of results for a file that hasn't executed a query
|
||||
|
||||
Reference in New Issue
Block a user