Skip to content

Commit

Permalink
Fix ClientCancellationAborts test dotnet#1379
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Apr 20, 2018
1 parent d69798d commit 8c3b83c
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -12,6 +12,7 @@
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -210,8 +211,8 @@ public async Task ClientDisposalCloses()
Task<int> readTask = responseStream.ReadAsync(new byte[100], 0, 100);
Assert.False(readTask.IsCompleted);
responseStream.Dispose();
Assert.True(readTask.Wait(TimeSpan.FromSeconds(10)), "Finished");
Assert.Equal(0, readTask.Result);
var result = await readTask.TimeoutAfter(TimeSpan.FromSeconds(10));
Assert.Equal(0, result);
block.Set();
}

Expand All @@ -235,8 +236,7 @@ public async Task ClientCancellationAborts()
Task<int> readTask = responseStream.ReadAsync(new byte[100], 0, 100, cts.Token);
Assert.False(readTask.IsCompleted, "Not Completed");
cts.Cancel();
var ex = Assert.Throws<AggregateException>(() => readTask.Wait(TimeSpan.FromSeconds(10)));
Assert.IsAssignableFrom<OperationCanceledException>(ex.GetBaseException());
await Assert.ThrowsAsync<OperationCanceledException>(() => readTask.TimeoutAfter(TimeSpan.FromSeconds(10)));
block.Set();
}

Expand Down

0 comments on commit 8c3b83c

Please sign in to comment.