Akka.Streams.Tests.Dsl.FlowGroupBySpec.WithSubstreamsSupport C# (CSharp) Method

WithSubstreamsSupport() private method

private WithSubstreamsSupport ( int groupCount = 2, int elementCount = 6, int maxSubstream = -1, NotUsed>.Action run = null ) : void
groupCount int
elementCount int
maxSubstream int
run NotUsed>.Action
return void
        private void WithSubstreamsSupport(int groupCount = 2, int elementCount = 6, int maxSubstream = -1,
            Action<TestSubscriber.ManualProbe<Tuple<int, Source<int, NotUsed>>>, ISubscription, Func<int, Source<int, NotUsed>>> run = null)
        {

            var source = Source.From(Enumerable.Range(1, elementCount)).RunWith(Sink.AsPublisher<int>(false), Materializer);
            var max = maxSubstream > 0 ? maxSubstream : groupCount;
            var groupStream =
                Source.FromPublisher(source)
                    .GroupBy(max, x => x%groupCount)
                    .Lift(x => x%groupCount)
                    .RunWith(Sink.AsPublisher<Tuple<int, Source<int, NotUsed>>>(false), Materializer);
            var masterSubscriber = TestSubscriber.CreateManualProbe<Tuple<int, Source<int, NotUsed>>>(this);

            groupStream.Subscribe(masterSubscriber);
            var masterSubscription = masterSubscriber.ExpectSubscription();

            run?.Invoke(masterSubscriber, masterSubscription, expectedKey =>
            {
                masterSubscription.Request(1);
                var tuple =  masterSubscriber.ExpectNext();
                tuple.Item1.Should().Be(expectedKey);
                return tuple.Item2;
            });
        }