Akka.Streams.Tests.Dsl.FlowJoinSpec.A_Flow_using_Join_must_allow_for_cycles C# (CSharp) Method

A_Flow_using_Join_must_allow_for_cycles() private method

private A_Flow_using_Join_must_allow_for_cycles ( ) : void
return void
        public void A_Flow_using_Join_must_allow_for_cycles()
        {
            this.AssertAllStagesStopped(() =>
            {
                const int end = 47;
                var t = Enumerable.Range(0, end + 1).GroupBy(i => i%2 == 0).ToList();
                var even = t.First(x => x.Key).ToList();
                var odd = t.First(x => !x.Key).ToList();
                var source = Source.From(Enumerable.Range(0, end + 1));
                var result = even.Concat(odd).Concat(odd.Select(x => x*10));
                var probe = TestSubscriber.CreateManualProbe<IEnumerable<int>>(this);

                var flow1 = Flow.FromGraph(GraphDsl.Create(b =>
                {
                    var merge = b.Add(new Merge<int>(2));
                    var broadcast = b.Add(new Broadcast<int>(2));
                    b.From(source).To(merge.In(0));
                    b.From(merge.Out).To(broadcast.In);
                    b.From(broadcast.Out(0))
                        .Via(Flow.Create<int>().Grouped(1000))
                        .To(Sink.FromSubscriber(probe));
                    return new FlowShape<int, int>(merge.In(1), broadcast.Out(1));
                }));

                var flow2 =
                    Flow.Create<int>()
                        .Where(x => x%2 == 1)
                        .Select(x => x*10)
                        .Buffer((end + 1)/2, OverflowStrategy.Backpressure)
                        .Take((end + 1)/2);

                flow1.Join(flow2).Run(Materializer);

                var sub = probe.ExpectSubscription();
                sub.Request(1);
                probe.ExpectNext().ShouldAllBeEquivalentTo(result);
                sub.Cancel();
            }, Materializer);
        }