public void A_Unzip_must_unzip_to_two_subscribers()
{
this.AssertAllStagesStopped(() =>
{
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.From(new[]
{
new KeyValuePair<int, string>(1, "a"),
new KeyValuePair<int, string>(2, "b"),
new KeyValuePair<int, string>(3, "c")
});
b.From(source).To(unzip.In);
b.From(unzip.Out0)
.Via(Flow.Create<int>().Buffer(16, OverflowStrategy.Backpressure).Select(x => x*2))
.To(Sink.FromSubscriber(c1));
b.From(unzip.Out1)
.Via(Flow.Create<string>().Buffer(16, OverflowStrategy.Backpressure))
.To(Sink.FromSubscriber(c2));
return ClosedShape.Instance;
})).Run(Materializer);
var sub1 = c1.ExpectSubscription();
var sub2 = c2.ExpectSubscription();
sub1.Request(1);
sub2.Request(2);
c1.ExpectNext(1*2);
c1.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
c2.ExpectNext("a", "b");
c2.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
sub1.Request(3);
c1.ExpectNext(2*2, 3*2);
c1.ExpectComplete();
sub2.Request(3);
c2.ExpectNext("c");
c2.ExpectComplete();
}, Materializer);
}