public async Task Head_without_pipeline_should_await_start() { var result = 0; var head = new HeadBlock <int>(async(token, func) => { for (var i = 0; i < 4; i++) { await func(token, i, new PipelineMetadata()); result += i; } }); var cts = new CancellationTokenSource().Token; await head.Start(cts).ConfigureAwait(false); result.Should().Be(6); }
public async Task Head_with_generator_should_await_blocks_when_have_one() { var result = 0; var head = new HeadBlock <int>(async(token, func) => { for (var i = 0; i < 4; i++) { await func(token, i, new PipelineMetadata()); } }); head.Action((ct, i, md) => Task.FromResult(result += i)); var cts = new CancellationTokenSource().Token; await head.Start(cts); result.Should().Be(6); }