@@ -108,25 +108,21 @@ private void EnlistedTransactionPreservedWhilePooled()
108
108
transactionException = ex ;
109
109
}
110
110
111
- if ( Utils . IsAzureSqlServer ( new SqlConnectionStringBuilder ( ( ConnectionString ) ) . DataSource ) )
112
- {
113
- // Even if an application swallows the command exception, completing the transaction should indicate that it failed.
114
- Assert . IsType < TransactionInDoubtException > ( transactionException ) ;
115
- // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-3000-to-3999?view=sql-server-ver16
116
- // Error 3971 corresponds to "The server failed to resume the transaction."
117
- Assert . Equal ( 3971 , ( ( SqlException ) commandException ) . Number ) ;
118
- }
119
- else
120
- {
121
- Assert . IsType < TransactionAbortedException > ( transactionException ) ;
111
+ // Even if an application swallows the command exception, completing the transaction should indicate that it failed.
112
+ var expectedTransactionExceptions = new [ ] { typeof ( TransactionAbortedException ) , typeof ( TransactionInDoubtException ) } ;
113
+ Assert . Contains ( transactionException . GetType ( ) , expectedTransactionExceptions ) ;
122
114
123
- #if NETFRAMEWORK
115
+ var expectedCommandExceptions = new [ ] { typeof ( SqlException ) , typeof ( InvalidOperationException ) } ;
116
+ Assert . Contains ( commandException . GetType ( ) , expectedCommandExceptions ) ;
117
+
118
+ if ( commandException is SqlException )
119
+ {
124
120
// See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-8000-to-8999?view=sql-server-ver16
125
121
// The distributed transaction failed
126
- Assert . Equal ( 8525 , ( ( SqlException ) commandException ) . Number ) ;
127
- #else
128
- Assert . IsType < InvalidOperationException > ( commandException ) ;
129
- #endif
122
+ // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-3000-to-3999?view=sql-server-ver16
123
+ // Error 3971 corresponds to "The server failed to resume the transaction."
124
+ var expectedExceptionCodes = new [ ] { 3971 , 8525 } ;
125
+ Assert . Contains ( ( ( SqlException ) commandException ) . Number , expectedExceptionCodes ) ;
130
126
}
131
127
132
128
// Verify that nothing made it into the database
0 commit comments