@@ -87,7 +87,7 @@ public void TransientFaultTest(uint errorCode)
8787 [ InlineData ( 42108 ) ]
8888 [ InlineData ( 42109 ) ]
8989 [ PlatformSpecific ( TestPlatforms . Windows ) ]
90- public async Task TransientFaultDisabledTestAsync ( uint errorCode )
90+ public void TransientFaultDisabledTestAsync ( uint errorCode )
9191 {
9292 using TransientFaultTDSServer server = TransientFaultTDSServer . StartTestServer ( true , true , errorCode ) ;
9393 SqlConnectionStringBuilder builder = new ( )
@@ -99,17 +99,9 @@ public async Task TransientFaultDisabledTestAsync(uint errorCode)
9999 } ;
100100
101101 using SqlConnection connection = new ( builder . ConnectionString ) ;
102- try
103- {
104- await connection . OpenAsync ( ) ;
105- Assert . False ( true , "Connection should not have opened." ) ;
106- }
107- catch ( SqlException e )
108- {
109- // FATAL Error, should result in closed connection.
110- Assert . Equal ( 20 , e . Class ) ;
111- Assert . Equal ( ConnectionState . Closed , connection . State ) ;
112- }
102+ Task < SqlException > e = Assert . ThrowsAsync < SqlException > ( async ( ) => await connection . OpenAsync ( ) ) ;
103+ Assert . Equal ( 20 , e . Result . Class ) ;
104+ Assert . Equal ( ConnectionState . Closed , connection . State ) ;
113105 }
114106
115107 [ ConditionalTheory ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsNotArmProcess ) ) ]
@@ -129,17 +121,9 @@ public void TransientFaultDisabledTest(uint errorCode)
129121 } ;
130122
131123 using SqlConnection connection = new ( builder . ConnectionString ) ;
132- try
133- {
134- connection . Open ( ) ;
135- Assert . False ( true , "Connection should not have opened." ) ;
136- }
137- catch ( SqlException e )
138- {
139- // FATAL Error, should result in closed connection.
140- Assert . Equal ( 20 , e . Class ) ;
141- Assert . Equal ( ConnectionState . Closed , connection . State ) ;
142- }
124+ SqlException e = Assert . Throws < SqlException > ( ( ) => connection . Open ( ) ) ;
125+ Assert . Equal ( 20 , e . Class ) ;
126+ Assert . Equal ( ConnectionState . Closed , connection . State ) ;
143127 }
144128
145129 [ Fact ]
0 commit comments