Convert Async to sync (SqlClient apis) and cleanup async usage (#2167)

This commit is contained in:
Cheena Malhotra
2023-08-09 15:03:02 -07:00
committed by GitHub
parent 65a7406063
commit 0820d9796a
20 changed files with 64 additions and 83 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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)