public void InputStreamSink_should_return_Exception_when_stream_is_failed()
{
this.AssertAllStagesStopped(() =>
{
var sinkProbe = CreateTestProbe();
var t = this.SourceProbe<ByteString>().ToMaterialized(TestSink(sinkProbe), Keep.Both).Run(_materializer);
var probe = t.Item1;
var inputStream = t.Item2;
var ex = new SystemException("Stream failed.");
probe.SendNext(_byteString);
sinkProbe.ExpectMsg<GraphStageMessages.Push>();
var r = ReadN(inputStream, _byteString.Count);
r.Item1.Should().Be(_byteString.Count);
r.Item2.ShouldBeEquivalentTo(_byteString);
probe.SendError(ex);
sinkProbe.ExpectMsg<GraphStageMessages.Failure>().Ex.Should().Be(ex);
var task = Task.Run(() => inputStream.ReadByte());
Action block = () => task.Wait(Timeout);
block.ShouldThrow<Exception>();
task.Exception.InnerException.Should().Be(ex);
}, _materializer);
}