public void A_Unzip_must_cancel_upstream_when_downstream_cancel()
{
this.AssertAllStagesStopped(() =>
{
var p1 = TestPublisher.CreateManualProbe<KeyValuePair<int, string>>(this);
var c1 = TestSubscriber.CreateManualProbe<int>(this);
var c2 = TestSubscriber.CreateManualProbe<string>(this);
RunnableGraph.FromGraph(GraphDsl.Create(b =>
{
var unzip = b.Add(new UnZip<int, string>());
var source = Source.FromPublisher(p1.Publisher);
b.From(source).To(unzip.In);
b.From(unzip.Out0).To(Sink.FromSubscriber(c1));
b.From(unzip.Out1).To(Sink.FromSubscriber(c2));
return ClosedShape.Instance;
})).Run(Materializer);
var p1Sub = p1.ExpectSubscription();
var sub1 = c1.ExpectSubscription();
var sub2 = c2.ExpectSubscription();
sub1.Request(3);
sub2.Request(3);
p1.ExpectRequest(p1Sub, 16);
p1Sub.SendNext(new KeyValuePair<int, string>(1, "a"));
c1.ExpectNext(1);
c2.ExpectNext("a");
p1Sub.SendNext(new KeyValuePair<int, string>(2, "b"));
c1.ExpectNext(2);
c2.ExpectNext("b");
sub1.Cancel();
sub2.Cancel();
p1Sub.ExpectCancellation();
}, Materializer);
}