public void OutputStreamSource_must_throw_IOException_when_writing_to_the_stream_after_the_subscriber_has_cancelled_the_reactive_stream() { this.AssertAllStagesStopped(() => { var sourceProbe = CreateTestProbe(); var t = TestSourceStage <ByteString, Stream> .Create(new OutputStreamSourceStage(Timeout), sourceProbe) .ToMaterialized(this.SinkProbe <ByteString>(), Keep.Both) .Run(_materializer); var outputStream = t.Item1; var probe = t.Item2; var s = probe.ExpectSubscription(); outputStream.Write(_bytesArray, 0, _bytesArray.Length); s.Request(1); sourceProbe.ExpectMsg <GraphStageMessages.Pull>(); probe.ExpectNext(_byteString); s.Cancel(); sourceProbe.ExpectMsg <GraphStageMessages.DownstreamFinish>(); Thread.Sleep(500); outputStream.Invoking(os => os.Write(_bytesArray, 0, _bytesArray.Length)).ShouldThrow <IOException>(); }, _materializer); }
public void QueueSource_should_remember_pull_from_downstream_to_send_offered_element_immediately() { this.AssertAllStagesStopped(() => { var s = this.CreateManualSubscriberProbe <int>(); var probe = CreateTestProbe(); var queue = TestSourceStage <int, ISourceQueueWithComplete <int> > .Create( new QueueSource <int>(1, OverflowStrategy.DropHead), probe) .To(Sink.FromSubscriber(s)) .Run(_materializer); var sub = s.ExpectSubscription(); sub.Request(1); probe.ExpectMsg <GraphStageMessages.Pull>(); AssertSuccess(queue.OfferAsync(1)); s.ExpectNext(1); sub.Cancel(); }, _materializer); }