public void A_AggregateAsync_must_complete_task_with_failure_when_Aggregateing_functions_throws() { this.AssertAllStagesStopped(() => { var error = new TestException("buh"); var future = InputSource.RunAggregateAsync(0, (x, y) => { if (x > 50) { var completion = new TaskCompletionSource <int>(); completion.SetException(error); return(completion.Task); } return(Task.Run(() => x + y)); }, Materializer); future.Invoking(f => f.Wait(TimeSpan.FromSeconds(3))) .ShouldThrow <TestException>() .And.Should().Be(error); }, Materializer); }