Esempio n. 1
0
        public void A_Flow_using_Join_must_allow_for_interleave_cycle()
        {
            this.AssertAllStagesStopped(() =>
            {
                var source = Source.Single("lonely traveler").MapMaterializedValue(_ => Task.FromResult(""));
                var flow   = Flow.FromGraph(GraphDsl.Create(Sink.First <string>(), (b, sink) =>
                {
                    var interleave = b.Add(Interleave.Create <string>(2, 1));
                    var broadcast  = b.Add(new Broadcast <string>(2, true));

                    b.From(source).To(interleave.In(0));
                    b.From(interleave.Out).To(broadcast.In);
                    b.From(broadcast.Out(0)).To(sink);
                    return(new FlowShape <string, string>(interleave.In(1), broadcast.Out(1)));
                }));

                var t = flow.Join(Flow.Create <string>()).Run(Materializer);
                t.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
                t.Result.Should().Be("lonely traveler");
            }, Materializer);
        }