mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Convert Async to sync (SqlClient apis) and cleanup async usage (#2167)
This commit is contained in:
@@ -528,10 +528,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData
|
||||
{
|
||||
// Get the command from the edit operation and execute it
|
||||
using (DbCommand editCommand = editOperation.GetCommand(connection))
|
||||
using (DbDataReader reader = await editCommand.ExecuteReaderAsync())
|
||||
using (DbDataReader reader = editCommand.ExecuteReader())
|
||||
{
|
||||
// Apply the changes of the command to the result set
|
||||
await editOperation.ApplyChanges(reader);
|
||||
editOperation.ApplyChanges(reader);
|
||||
}
|
||||
}
|
||||
catch (EditDataDeleteException)
|
||||
|
||||
@@ -12,7 +12,6 @@ using System.Data.Common;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
@@ -74,11 +73,11 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
/// Reader returned from the execution of the command to insert a new row. Should contain
|
||||
/// a single row that represents the newly added row.
|
||||
/// </param>
|
||||
public override Task ApplyChanges(DbDataReader dataReader)
|
||||
public override void ApplyChanges(DbDataReader dataReader)
|
||||
{
|
||||
Validate.IsNotNull(nameof(dataReader), dataReader);
|
||||
|
||||
return AssociatedResultSet.AddRow(dataReader);
|
||||
AssociatedResultSet.AddRow(dataReader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,7 +9,6 @@ using System;
|
||||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
@@ -71,11 +70,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
/// Reader returned from the execution of the command to insert a new row. Should NOT
|
||||
/// contain any rows.
|
||||
/// </param>
|
||||
public override Task ApplyChanges(DbDataReader dataReader)
|
||||
public override void ApplyChanges(DbDataReader dataReader)
|
||||
{
|
||||
// Take the result set and remove the row from it
|
||||
AssociatedResultSet.RemoveRow(RowId);
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,7 +10,6 @@ using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
@@ -86,7 +85,7 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
/// <param name="dataReader">
|
||||
/// Data reader from execution of the command to commit the change to the db
|
||||
/// </param>
|
||||
public abstract Task ApplyChanges(DbDataReader dataReader);
|
||||
public abstract void ApplyChanges(DbDataReader dataReader);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a command that will commit the change to the db
|
||||
|
||||
@@ -14,7 +14,6 @@ using Microsoft.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
@@ -74,10 +73,10 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
/// Reader returned from the execution of the command to update a row. Should contain
|
||||
/// a single row that represents all the values of the row.
|
||||
/// </param>
|
||||
public override Task ApplyChanges(DbDataReader dataReader)
|
||||
public override void ApplyChanges(DbDataReader dataReader)
|
||||
{
|
||||
Validate.IsNotNull(nameof(dataReader), dataReader);
|
||||
return AssociatedResultSet.UpdateRow(RowId, dataReader);
|
||||
AssociatedResultSet.UpdateRow(RowId, dataReader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,8 +12,6 @@ using System.Data.SqlTypes;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
@@ -83,17 +81,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
||||
|
||||
#region DbDataReader Methods
|
||||
|
||||
/// <summary>
|
||||
/// Pass-through to DbDataReader.ReadAsync()
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token to use for cancelling a query</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Deprecated due to performance issues, please use Read() instead.")]
|
||||
public Task<bool> ReadAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return DbDataReader.ReadAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass-through to DbDataReader.Read()
|
||||
///
|
||||
|
||||
@@ -449,10 +449,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// Adds a new row to the result set by reading the row from the provided db data reader
|
||||
/// </summary>
|
||||
/// <param name="dbDataReader">The result of a command to insert a new row should be UNREAD</param>
|
||||
public async Task AddRow(DbDataReader dbDataReader)
|
||||
public void AddRow(DbDataReader dbDataReader)
|
||||
{
|
||||
// Write the new row to the end of the file
|
||||
long newOffset = await AppendRowToBuffer(dbDataReader);
|
||||
long newOffset = AppendRowToBuffer(dbDataReader);
|
||||
|
||||
// Add the row to file offset list
|
||||
fileOffsets.Add(newOffset);
|
||||
@@ -464,10 +464,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// <param name="rowId"></param>
|
||||
/// <param name="dbDataReader"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateRow(long rowId, DbDataReader dbDataReader)
|
||||
public void UpdateRow(long rowId, DbDataReader dbDataReader)
|
||||
{
|
||||
// Write the updated row to the end of the file
|
||||
long newOffset = await AppendRowToBuffer(dbDataReader);
|
||||
long newOffset = AppendRowToBuffer(dbDataReader);
|
||||
|
||||
// Update the file offset of the row in question
|
||||
fileOffsets[rowId] = newOffset;
|
||||
@@ -782,7 +782,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// </summary>
|
||||
/// <param name="dbDataReader">An UNREAD db data reader</param>
|
||||
/// <returns>The offset into the file where the row was inserted</returns>
|
||||
private async Task<long> AppendRowToBuffer(DbDataReader dbDataReader)
|
||||
private long AppendRowToBuffer(DbDataReader dbDataReader)
|
||||
{
|
||||
Validate.IsNotNull(nameof(dbDataReader), dbDataReader);
|
||||
// Sanity check to make sure that results read has started
|
||||
@@ -793,11 +793,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
// NOTE: We are no longer checking to see if the data reader has rows before reading
|
||||
// b/c of a quirk in SqlClient. In some scenarios, a SqlException isn't thrown until we
|
||||
// read. In order to get appropriate errors back to the user, we'll read first.
|
||||
// Returning false from .ReadAsync means there aren't any rows.
|
||||
// Returning false from .Read means there aren't any rows.
|
||||
|
||||
// Create a storage data reader, read it, make sure there were results
|
||||
var dataReader = new StorageDataReader(dbDataReader);
|
||||
if (!await dataReader.ReadAsync(CancellationToken.None))
|
||||
if (!dataReader.Read())
|
||||
{
|
||||
throw new InvalidOperationException(SR.QueryServiceResultSetAddNoRows);
|
||||
}
|
||||
|
||||
@@ -1498,7 +1498,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrOpenNullOwnerUri([Values(null, "")] string ownerUri)
|
||||
public void 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
|
||||
@@ -1508,7 +1508,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrOpenNullConnectionType([Values(null, "")] string connType)
|
||||
public void 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
|
||||
@@ -1518,7 +1518,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrOpenNoConnection()
|
||||
public void GetOrOpenNoConnection()
|
||||
{
|
||||
// If: I have a connection service and I ask for a connection for an unconnected uri
|
||||
// Then: An exception should be thrown
|
||||
@@ -1528,7 +1528,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrOpenNoDefaultConnection()
|
||||
public void GetOrOpenNoDefaultConnection()
|
||||
{
|
||||
// Setup: Create a connection service with an empty connection info obj
|
||||
var service = TestObjects.GetTestConnectionService();
|
||||
@@ -1542,7 +1542,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrOpenAdminDefaultConnection()
|
||||
public void GetOrOpenAdminDefaultConnection()
|
||||
{
|
||||
// Setup: Create a connection service with an empty connection info obj
|
||||
var service = TestObjects.GetTestConnectionService();
|
||||
@@ -1883,7 +1883,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
/// Verify that providing an empty password to change password will fire an error.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ConnectionEmptyPasswordChange()
|
||||
public void ConnectionEmptyPasswordChange()
|
||||
{
|
||||
var serviceHostMock = new Mock<IProtocolEndpoint>();
|
||||
|
||||
@@ -1905,7 +1905,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
/// Verify that providing an invalid connection parameter value to change password will fire an error.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ConnectionInvalidParamPasswordChange()
|
||||
public void ConnectionInvalidParamPasswordChange()
|
||||
{
|
||||
var serviceHostMock = new Mock<IProtocolEndpoint>();
|
||||
|
||||
@@ -1927,7 +1927,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
|
||||
/// Verify that providing a non actual connection and a fake password to change password will throw an error.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task InvalidConnectionPasswordChange()
|
||||
public void InvalidConnectionPasswordChange()
|
||||
{
|
||||
var serviceHostMock = new Mock<IProtocolEndpoint>();
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
|
||||
// If: I ask for the change to be applied
|
||||
var rc = new RowCreate(rowId, rs, data.TableMetadata);
|
||||
await rc.ApplyChanges(newRowReader);
|
||||
rc.ApplyChanges(newRowReader);
|
||||
|
||||
// Then: The result set should have an additional row in it
|
||||
Assert.AreEqual(2, rs.RowCount);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
|
||||
// If: I ask for the change to be applied
|
||||
RowDelete rd = new RowDelete(0, rs, data.TableMetadata);
|
||||
await rd.ApplyChanges(null); // Reader not used, can be null
|
||||
rd.ApplyChanges(null); // Reader not used, can be null
|
||||
|
||||
// Then : The result set should have one less row in it
|
||||
Assert.AreEqual(0, rs.RowCount);
|
||||
@@ -209,7 +209,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
};
|
||||
var testResultSet = new TestResultSet(data.DbColumns, rows);
|
||||
var newRowReader = new TestDbDataReader(new[] { testResultSet }, false);
|
||||
await ru.ApplyChanges(newRowReader);
|
||||
ru.ApplyChanges(newRowReader);
|
||||
|
||||
// ... Create a row delete.
|
||||
RowDelete rd = new RowDelete(0, rs, data.TableMetadata);
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Task ApplyChanges(DbDataReader reader)
|
||||
public override void ApplyChanges(DbDataReader reader)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
var newRowReader = Common.GetNewRowDataReader(data.DbColumns, includeIdentity);
|
||||
|
||||
// If: I ask for the change to be applied
|
||||
await ru.ApplyChanges(newRowReader);
|
||||
ru.ApplyChanges(newRowReader);
|
||||
|
||||
// Then:
|
||||
// ... The result set should have the same number of rows as before
|
||||
@@ -422,7 +422,7 @@ 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
|
||||
Assert.ThrowsAsync<ArgumentNullException>(() => ru.ApplyChanges(null));
|
||||
Assert.Throws<ArgumentNullException>(() => ru.ApplyChanges(null));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
#region Initialize Tests
|
||||
[Test]
|
||||
[Sequential]
|
||||
public async Task InitializeNullParams([Values(null, Common.OwnerUri, Common.OwnerUri)] string ownerUri,
|
||||
public void InitializeNullParams([Values(null, Common.OwnerUri, Common.OwnerUri)] string ownerUri,
|
||||
[Values("table", null, "table")] string objName,
|
||||
[Values("table", "table", null)] string objType)
|
||||
{
|
||||
|
||||
@@ -803,7 +803,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
#region SubSet Tests
|
||||
|
||||
[Test]
|
||||
public async Task SubsetNotInitialized()
|
||||
public void SubsetNotInitialized()
|
||||
{
|
||||
// Setup:
|
||||
// ... Create a session without initializing
|
||||
@@ -1108,7 +1108,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
|
||||
// ... Add a mock commands for fun
|
||||
var edit = new Mock<RowEditBase>();
|
||||
edit.Setup(e => e.GetCommand(It.IsAny<DbConnection>())).Returns<DbConnection>(dbc => dbc.CreateCommand());
|
||||
edit.Setup(e => e.ApplyChanges(It.IsAny<DbDataReader>())).Returns(Task.FromResult(0));
|
||||
s.EditCache[0] = edit.Object;
|
||||
|
||||
// If: I commit these changes (and await completion)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
public class FirewallRuleServiceTest
|
||||
{
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenNullServerName()
|
||||
public void CreateShouldThrowExceptionGivenNullServerName()
|
||||
{
|
||||
string serverName = null;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenNullStartIp()
|
||||
public void CreateShouldThrowExceptionGivenNullStartIp()
|
||||
{
|
||||
string serverName = "serverName";
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenInvalidEndIp()
|
||||
public void CreateShouldThrowExceptionGivenInvalidEndIp()
|
||||
{
|
||||
string serverName = "serverName";
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenInvalidStartIp()
|
||||
public void CreateShouldThrowExceptionGivenInvalidStartIp()
|
||||
{
|
||||
string serverName = "serverName";
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenNullEndIp()
|
||||
public void CreateShouldThrowExceptionGivenNullEndIp()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
testContext.EndIpAddress = null;
|
||||
@@ -72,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionIfUserIsNotLoggedIn()
|
||||
public void CreateShouldThrowExceptionIfUserIsNotLoggedIn()
|
||||
{
|
||||
var applicationAuthenticationManagerMock = new Mock<IAzureAuthenticationManager>();
|
||||
applicationAuthenticationManagerMock.Setup(x => x.GetUserNeedsReauthenticationAsync()).Throws(new ApplicationException());
|
||||
@@ -89,7 +89,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionIfUserDoesNotHaveSubscriptions()
|
||||
public void CreateShouldThrowExceptionIfUserDoesNotHaveSubscriptions()
|
||||
{
|
||||
var applicationAuthenticationManagerMock =
|
||||
new Mock<IAzureAuthenticationManager>();
|
||||
@@ -109,7 +109,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionIfAuthenticationManagerFailsToReturnSubscription()
|
||||
public void CreateShouldThrowExceptionIfAuthenticationManagerFailsToReturnSubscription()
|
||||
{
|
||||
var applicationAuthenticationManagerMock = new Mock<IAzureAuthenticationManager>();
|
||||
applicationAuthenticationManagerMock.Setup(x => x.GetUserNeedsReauthenticationAsync()).Returns(Task.FromResult(false));
|
||||
@@ -127,7 +127,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionGivenNoSubscriptionFound()
|
||||
public void CreateShouldThrowExceptionGivenNoSubscriptionFound()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
testContext = CreateMocks(testContext);
|
||||
@@ -242,7 +242,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateThrowExceptionIfResourceNotFound()
|
||||
public void CreateThrowExceptionIfResourceNotFound()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
var resources = new List<IAzureSqlServerResource>
|
||||
@@ -258,7 +258,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateThrowExceptionIfResourcesIsEmpty()
|
||||
public void CreateThrowExceptionIfResourcesIsEmpty()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionIfThereIsNoSubscriptionForUser()
|
||||
public void CreateShouldThrowExceptionIfThereIsNoSubscriptionForUser()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
testContext.Subscriptions = new List<IAzureUserAccountSubscriptionContext>();
|
||||
@@ -281,7 +281,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ResourceProvider
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task CreateShouldThrowExceptionIfSubscriptionIsInAnotherAccount()
|
||||
public void CreateShouldThrowExceptionIfSubscriptionIsInAnotherAccount()
|
||||
{
|
||||
ServiceTestContext testContext = new ServiceTestContext();
|
||||
testContext.Subscriptions = new List<IAzureUserAccountSubscriptionContext>
|
||||
|
||||
Reference in New Issue
Block a user