Permalink
Browse files

TaskSample - OneItemThrowsAsyncThrowsInvalidOperation

  • Loading branch information...
bobbymcr committed May 23, 2018
1 parent fd8bd1b commit a830e65bd0824b59e71492a201aaacc683aa67d1
Showing with 22 additions and 0 deletions.
  1. +22 −0 projects/TaskSample/TaskSample.Test/FirstAsyncTest.cs
@@ -64,6 +64,28 @@ public void OneItemThrowsSyncThrowsInvalidOperation()
.Message.Should().Be("No matching result.");
}
[Fact]
public void OneItemThrowsAsyncThrowsInvalidOperation()
{
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
IEnumerable<Func<CancellationToken, Task<string>>> funcs = new Func<CancellationToken, Task<string>>[]
{
t => tcs.Task
};
Task<string> task = funcs.FirstAsync(r => true);
task.IsCompleted.Should().BeFalse();
tcs.SetException(new BadImageFormatException("!!!"));
task.IsCompleted.Should().BeTrue();
task.Exception.Should().NotBeNull();
task.Exception.InnerException.Should()
.BeOfType<InvalidOperationException>().Which
.Message.Should().Be("No matching result.");
}
[Fact]
public void TwoItemsFirstMatchesSyncReturns()
{

0 comments on commit a830e65

Please sign in to comment.