Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace public async void with public async Task for XUnit #2948

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.Data.SqlClient.Tests
{
public class SqlConfigurableRetryLogicTest
{
[Fact]
public async void InvalidExecute()
public async Task InvalidExecute()
{
SqlRetryLogicOption option = new SqlRetryLogicOption()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void ConnectionTimeoutTest(int timeout)
[InlineData(10)]
[InlineData(5)]
[InlineData(1)]
public async void ConnectionTimeoutTestAsync(int timeout)
public async Task ConnectionTimeoutTestAsync(int timeout)
{
// Start a server with connection timeout from the inline data.
using TestTdsServer server = TestTdsServer.StartTestServer(false, false, timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ public void TestExecuteReader(string connection)

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsTargetReadyForAeWithKeyStore))]
[ClassData(typeof(AEConnectionStringProvider))]
public async void TestExecuteReaderAsyncWithLargeQuery(string connectionString)
public async Task TestExecuteReaderAsyncWithLargeQuery(string connectionString)
{
string randomName = DataTestUtility.GetUniqueName(Guid.NewGuid().ToString().Replace("-", ""), false);
if (randomName.Length > 50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Xunit;
Expand Down Expand Up @@ -71,7 +72,7 @@ public static void ExceptionTest()

// Synapse: Parse error at line: 1, column: 29: Incorrect syntax near 'FOR'.
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MoveToContentAsyncTest()
public static async Task MoveToContentAsyncTest()
{
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
using (SqlCommand command = new SqlCommand(CommandText, connection))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Data;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
Expand Down Expand Up @@ -87,7 +88,7 @@ public static void EnvironmentHostNameSPIDTest()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static async void ConnectionTimeoutInfiniteTest()
public static async Task ConnectionTimeoutInfiniteTest()
{
// Exercise the special-case infinite connect timeout code path
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static async Task GetFieldValueAsync_Char_OfTextReader(CommandBehavior be
// Synapse: Cannot find data type 'XML'.
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetFieldValue_OfXmlReader(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetFieldValue_OfXmlReader(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -191,7 +191,7 @@ public static async void GetFieldValue_OfXmlReader(CommandBehavior behavior, boo

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetFieldValue_OfStream(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetFieldValue_OfStream(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -224,7 +224,7 @@ public static async void GetFieldValue_OfStream(CommandBehavior behavior, bool i

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetFieldValue_OfTextReader(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetFieldValue_OfTextReader(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -258,7 +258,7 @@ public static async void GetFieldValue_OfTextReader(CommandBehavior behavior, bo

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetStream(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetStream(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -294,7 +294,7 @@ public static async void GetStream(CommandBehavior behavior, bool isExecuteAsync

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetXmlReader(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetXmlReader(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -328,7 +328,7 @@ public static async void GetXmlReader(CommandBehavior behavior, bool isExecuteAs

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(GetCommandBehavioursAndIsAsync))]
public static async void GetTextReader(CommandBehavior behavior, bool isExecuteAsync)
public static async Task GetTextReader(CommandBehavior behavior, bool isExecuteAsync)
{
const int PacketSize = 512; // force minimun packet size so that the test data spans multiple packets to test sequential access spanning
string connectionString = SetConnectionStringPacketSize(DataTestUtility.TCPConnectionString, PacketSize);
Expand Down Expand Up @@ -474,7 +474,7 @@ public static void InvalidCastExceptionStream(CommandBehavior behavior, Accessor

#if NET6_0_OR_GREATER
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void ReadAsyncContentsCompletes()
public static async Task ReadAsyncContentsCompletes()
{
string expectedXml = "<test>This is a test string</test>";
string query = $"SELECT CAST('{expectedXml}' AS NVARCHAR(MAX))";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static void MARSSyncBusyReaderTest()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MARSAsyncExecuteNonQueryTest()
public static async Task MARSAsyncExecuteNonQueryTest()
{
using SqlConnection con = new(_connStr);
con.Open();
Expand Down Expand Up @@ -298,7 +298,7 @@ public static void MARSSyncExecuteNonQueryTest()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MARSAsyncExecuteReaderTest1()
public static async Task MARSAsyncExecuteReaderTest1()
{
using SqlConnection con = new(_connStr);
con.Open();
Expand Down Expand Up @@ -412,7 +412,7 @@ public static void MARSSyncExecuteReaderTest1()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MARSAsyncExecuteReaderTest2()
public static async Task MARSAsyncExecuteReaderTest2()
{
using SqlConnection con = new(_connStr);
con.Open();
Expand Down Expand Up @@ -463,7 +463,7 @@ public static void MARSSyncExecuteReaderTest2()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MARSAsyncExecuteReaderTest3()
public static async Task MARSAsyncExecuteReaderTest3()
{
using SqlConnection con = new(_connStr);
con.Open();
Expand Down Expand Up @@ -525,7 +525,7 @@ public static void MARSSyncExecuteReaderTest3()
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public static async void MARSAsyncExecuteReaderTest4()
public static async Task MARSAsyncExecuteReaderTest4()
{
using SqlConnection con = new(_connStr);
con.Open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class RetryLogicCounterTest
[InlineData("ExecuteReaderAsync", 3)]
[InlineData("ExecuteXmlReaderAsync", 3)]
[InlineData("ExecuteNonQueryAsync", 3)]
public async void ValidateRetryCount_SqlCommand_Async(string methodName, int numOfTries)
public async Task ValidateRetryCount_SqlCommand_Async(string methodName, int numOfTries)
{
ErrorInfoRetryLogicProvider _errorInfoRetryProvider = new(
SqlConfigurableRetryFactory.CreateFixedRetryProvider(new SqlRetryLogicOption()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public void NoneRetriableExecuteFail(string cnnString, SqlRetryLogicBaseProvider
#region Async
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCommand), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
public async void RetryExecuteAsyncFail(string cnnString, SqlRetryLogicBaseProvider provider)
public async Task RetryExecuteAsyncFail(string cnnString, SqlRetryLogicBaseProvider provider)
{
int numberOfTries = provider.RetryLogic.NumberOfTries;
int cancelAfterRetries = numberOfTries + 1;
Expand Down Expand Up @@ -483,7 +483,7 @@ public async void RetryExecuteAsyncFail(string cnnString, SqlRetryLogicBaseProvi

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCommand), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
public async void RetryExecuteAsyncCancel(string cnnString, SqlRetryLogicBaseProvider provider)
public async Task RetryExecuteAsyncCancel(string cnnString, SqlRetryLogicBaseProvider provider)
{
int numberOfTries = provider.RetryLogic.NumberOfTries;
int cancelAfterRetries = numberOfTries - 1;
Expand Down Expand Up @@ -567,7 +567,7 @@ public void ConcurrentExecution(string cnnString, SqlRetryLogicBaseProvider prov

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCommand), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
public async void ConcurrentExecutionAsync(string cnnString, SqlRetryLogicBaseProvider provider)
public async Task ConcurrentExecutionAsync(string cnnString, SqlRetryLogicBaseProvider provider)
{
string query = "SELECT bad command";
await ProcessDataAsAsync(cnnString, provider, query, cmd => cmd.ExecuteScalarAsync());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void DefaultOpenWithoutRetry(string connectionString, SqlRetryLogicBasePr
// Test relies on error 4060 for automatic retry, which is not reliable when using Azure or AAD auth
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCatalog), parameters: new object[] { 5 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
public async void ConnectionRetryOpenAsyncInvalidCatalogFailed(string cnnString, SqlRetryLogicBaseProvider provider)
public async Task ConnectionRetryOpenAsyncInvalidCatalogFailed(string cnnString, SqlRetryLogicBaseProvider provider)
{
int numberOfTries = provider.RetryLogic.NumberOfTries;
int cancelAfterRetries = numberOfTries + 1;
Expand All @@ -178,7 +178,7 @@ public async void ConnectionRetryOpenAsyncInvalidCatalogFailed(string cnnString,
// Test relies on error 4060 for automatic retry, which is not returned when using AAD auth
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.TcpConnectionStringDoesNotUseAadAuth))]
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCatalog), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
public async void ConnectionCancelRetryOpenAsyncInvalidCatalog(string cnnString, SqlRetryLogicBaseProvider provider)
public async Task ConnectionCancelRetryOpenAsyncInvalidCatalog(string cnnString, SqlRetryLogicBaseProvider provider)
{
int numberOfTries = provider.RetryLogic.NumberOfTries;
int cancelAfterRetries = numberOfTries - 1;
Expand Down
Loading