Permalink
Browse files

TaskSample - OneItemMatchesAsyncReturns

  • Loading branch information...
bobbymcr committed May 23, 2018
1 parent c48413b commit eb02ad666004f1d9ef0e6e5afd595effef3bf6cb
Showing with 19 additions and 0 deletions.
  1. +19 −0 projects/TaskSample/TaskSample.Test/FirstAsyncTest.cs
@@ -28,6 +28,25 @@ public void OneItemMatchesSyncReturns()
task.Result.Should().Be("good");
}
[Fact]
public void OneItemMatchesAsyncReturns()
{
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.SetResult("good");
task.IsCompletedSuccessfully.Should().BeTrue();
task.Result.Should().Be("good");
}
[Fact]
public void TwoItemsFirstMatchesSyncReturns()
{

0 comments on commit eb02ad6

Please sign in to comment.