File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/libraries/System.Net.Requests/tests Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2267,9 +2267,22 @@ public void SendHttpRequest_BindIPEndPoint_Throws()
2267
2267
// URI shouldn't matter because it should throw exception before connection open.
2268
2268
HttpWebRequest request = WebRequest . CreateHttp ( Configuration . Http . RemoteEchoServer ) ;
2269
2269
request . ServicePoint . BindIPEndPointDelegate = ( _ , _ , _ ) => ( IPEndPoint ) socket . LocalEndPoint ! ;
2270
- var exception = await Assert . ThrowsAsync < WebException > ( ( ) =>
2271
- bool . Parse ( async) ? request . GetResponseAsync ( ) : Task . Run ( ( ) => request . GetResponse ( ) ) ) ;
2272
- Assert . IsType < OverflowException > ( exception . InnerException ? . InnerException ) ;
2270
+ try
2271
+ {
2272
+ if ( bool . Parse ( async) )
2273
+ {
2274
+ await request . GetResponseAsync ( ) ;
2275
+ }
2276
+ else
2277
+ {
2278
+ request . GetResponse ( ) ;
2279
+ }
2280
+ Assert . Fail ( "Should throw OverflowException" ) ;
2281
+ }
2282
+ catch ( Exception ex )
2283
+ {
2284
+ Assert . IsType < OverflowException > ( ex . InnerException ? . InnerException ) ;
2285
+ }
2273
2286
}
2274
2287
finally
2275
2288
{
You can’t perform that action at this time.
0 commit comments