Skip to content

Commit 47d7f27

Browse files
committed
Change exception handling on remote executor test
1 parent 05af2e0 commit 47d7f27

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,9 +2267,22 @@ public void SendHttpRequest_BindIPEndPoint_Throws()
22672267
// URI shouldn't matter because it should throw exception before connection open.
22682268
HttpWebRequest request = WebRequest.CreateHttp(Configuration.Http.RemoteEchoServer);
22692269
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+
}
22732286
}
22742287
finally
22752288
{

0 commit comments

Comments
 (0)