Skip to content

Commit

Permalink
Fixed hanging tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ManickaP committed Jun 23, 2020
1 parent 7e5c47d commit 96eccce
Showing 1 changed file with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,12 @@ public async Task Send_TimeoutRequestContent_Throws()
await LoopbackServer.CreateClientAndServerAsync(
async uri =>
{
try
{
var sendTask = Task.Run(() => {
using HttpClient httpClient = CreateHttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(0.5);
var sendTask = Task.Run(() => {
using HttpClient httpClient = CreateHttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(0.5);
try
{
HttpResponseMessage response = httpClient.Send(new HttpRequestMessage(HttpMethod.Get, uri) {
Content = new CustomContent(new Action<Stream>(stream =>
{
Expand All @@ -888,15 +888,15 @@ await LoopbackServer.CreateClientAndServerAsync(
}
}))
});
});
}
finally
{
mres.Set();
}
});
TaskCanceledException ex = await Assert.ThrowsAsync<TaskCanceledException>(() => sendTask);
Assert.IsType<TimeoutException>(ex.InnerException);
}
finally
{
mres.Set();
}
TaskCanceledException ex = await Assert.ThrowsAsync<TaskCanceledException>(() => sendTask);
Assert.IsType<TimeoutException>(ex.InnerException);
},
async server =>
{
Expand Down Expand Up @@ -966,22 +966,21 @@ public async Task Send_TimeoutResponseContent_Throws()
await LoopbackServer.CreateClientAndServerAsync(
async uri =>
{
try
{
var sendTask = Task.Run(() => {
using HttpClient httpClient = CreateHttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(0.5);
var sendTask = Task.Run(() => {
using HttpClient httpClient = CreateHttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(0.5);
try
{
HttpResponseMessage response = httpClient.Send(new HttpRequestMessage(HttpMethod.Get, uri));
});
}
finally
{
mres.Set();
}
});
TaskCanceledException ex = await Assert.ThrowsAsync<TaskCanceledException>(() => sendTask);
Assert.IsType<TimeoutException>(ex.InnerException);
}
finally
{
mres.Set();
}
TaskCanceledException ex = await Assert.ThrowsAsync<TaskCanceledException>(() => sendTask);
Assert.IsType<TimeoutException>(ex.InnerException);
},
async server =>
{
Expand Down

0 comments on commit 96eccce

Please sign in to comment.