@@ -48,15 +48,15 @@ public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit()
4848 private static bool s_EnlistedTransactionPreservedWhilePooledCondition => DataTestUtility . AreConnStringsSetup ( ) && DataTestUtility . IsNotX86Architecture ;
4949
5050 [ ConditionalFact ( nameof ( s_EnlistedTransactionPreservedWhilePooledCondition ) , Timeout = 10000 ) ]
51- public void Test_EnlistedTransactionPreservedWhilePooled ( )
51+ public async Task Test_EnlistedTransactionPreservedWhilePooled ( )
5252 {
5353#if NET
5454 TransactionManager . ImplicitDistributedTransactions = true ;
5555#endif
56- RunTestSet ( EnlistedTransactionPreservedWhilePooled ) ;
56+ await RunTestSet ( EnlistedTransactionPreservedWhilePooled ) ;
5757 }
5858
59- private void EnlistedTransactionPreservedWhilePooled ( )
59+ private async Task EnlistedTransactionPreservedWhilePooled ( )
6060 {
6161 Exception commandException = null ;
6262 Exception transactionException = null ;
@@ -67,7 +67,7 @@ private void EnlistedTransactionPreservedWhilePooled()
6767 {
6868 // Leave first connection open so that the transaction is promoted
6969 SqlConnection rootConnection = new SqlConnection ( ConnectionString ) ;
70- rootConnection . Open ( ) ;
70+ await rootConnection . OpenAsync ( ) ;
7171 using ( SqlCommand command = rootConnection . CreateCommand ( ) )
7272 {
7373 command . CommandText = $ "INSERT INTO { TestTableName } VALUES ({ InputCol1 } , '{ InputCol2 } ')";
@@ -109,25 +109,25 @@ private void EnlistedTransactionPreservedWhilePooled()
109109 }
110110
111111 // Even if an application swallows the command exception, completing the transaction should indicate that it failed.
112- var expectedTransactionExceptions = new [ ] { typeof ( TransactionAbortedException ) , typeof ( TransactionInDoubtException ) } ;
112+ Type [ ] expectedTransactionExceptions = new [ ] { typeof ( TransactionAbortedException ) , typeof ( TransactionInDoubtException ) } ;
113113 Assert . Contains ( transactionException . GetType ( ) , expectedTransactionExceptions ) ;
114114
115- var expectedCommandExceptions = new [ ] { typeof ( SqlException ) , typeof ( InvalidOperationException ) } ;
115+ Type [ ] expectedCommandExceptions = new [ ] { typeof ( SqlException ) , typeof ( InvalidOperationException ) } ;
116116 Assert . Contains ( commandException . GetType ( ) , expectedCommandExceptions ) ;
117117
118- if ( commandException is SqlException )
118+ if ( commandException is SqlException exception )
119119 {
120120 // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-8000-to-8999?view=sql-server-ver16
121121 // The distributed transaction failed
122122 // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-3000-to-3999?view=sql-server-ver16
123123 // Error 3971 corresponds to "The server failed to resume the transaction."
124124 var expectedExceptionCodes = new [ ] { 3971 , 8525 } ;
125- Assert . Contains ( ( ( SqlException ) commandException ) . Number , expectedExceptionCodes ) ;
125+ Assert . Contains ( exception . Number , expectedExceptionCodes ) ;
126126 }
127127
128128 // Verify that nothing made it into the database
129129 DataTable result = DataTestUtility . RunQuery ( ConnectionString , $ "select col2 from { TestTableName } where col1 = { InputCol1 } ") ;
130- Assert . True ( result . Rows . Count == 0 ) ;
130+ Assert . Equal ( 0 , result . Rows . Count ) ;
131131 }
132132
133133 private void KillProcess ( int serverProcessId )
@@ -152,7 +152,7 @@ private void KillProcess(int serverProcessId)
152152 private const int InputCol1 = 1 ;
153153 private const string InputCol2 = "One" ;
154154
155- private static void RunTestSet ( Action TestCase )
155+ private static async Task RunTestSet ( Func < Task > TestCase )
156156 {
157157 SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder ( DataTestUtility . TCPConnectionString ) ;
158158
@@ -165,7 +165,7 @@ private static void RunTestSet(Action TestCase)
165165 DataTestUtility . RunNonQuery ( ConnectionString , $ "create table { TestTableName } (col1 int, col2 text)") ;
166166 try
167167 {
168- TestCase ( ) ;
168+ await TestCase ( ) ;
169169 }
170170 finally
171171 {
0 commit comments