Skip to content

Commit

Permalink
Change exception handling on remote executor test
Browse files Browse the repository at this point in the history
  • Loading branch information
liveans committed Feb 28, 2024
1 parent 05af2e0 commit 47d7f27
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2267,9 +2267,22 @@ public void SendHttpRequest_BindIPEndPoint_Throws()
// URI shouldn't matter because it should throw exception before connection open.
HttpWebRequest request = WebRequest.CreateHttp(Configuration.Http.RemoteEchoServer);
request.ServicePoint.BindIPEndPointDelegate = (_, _, _) => (IPEndPoint)socket.LocalEndPoint!;
var exception = await Assert.ThrowsAsync<WebException>(() =>
bool.Parse(async) ? request.GetResponseAsync() : Task.Run(() => request.GetResponse()));
Assert.IsType<OverflowException>(exception.InnerException?.InnerException);
try
{
if (bool.Parse(async))
{
await request.GetResponseAsync();
}
else
{
request.GetResponse();
}
Assert.Fail("Should throw OverflowException");
}
catch (Exception ex)
{
Assert.IsType<OverflowException>(ex.InnerException?.InnerException);
}
}
finally
{
Expand Down

0 comments on commit 47d7f27

Please sign in to comment.