Akka.Streams.Tests.Dsl.FlowGroupedWithinSpec.A_GroupedWithin_must_reset_time_window_when_max_elements_reached C# (CSharp) Method

A_GroupedWithin_must_reset_time_window_when_max_elements_reached() private method

        public void A_GroupedWithin_must_reset_time_window_when_max_elements_reached()
        {
            var input = new Iterator<int>(Enumerable.Range(1, 10000));
            var upstream = TestPublisher.CreateProbe<int>(this);
            var downstream = TestSubscriber.CreateProbe<IEnumerable<int>>(this);

            Source.FromPublisher(upstream)
                .GroupedWithin(3, TimeSpan.FromSeconds(2))
                .To(Sink.FromSubscriber(downstream))
                .Run(Materializer);

            downstream.Request(2);
            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(1000));

            Enumerable.Range(1,4).ForEach(_=>upstream.SendNext(input.Next()));
            downstream.Within(TimeSpan.FromMilliseconds(1000), () =>
            {
                downstream.ExpectNext().ShouldAllBeEquivalentTo(new[] {1, 2, 3});
                return NotUsed.Instance;
            });

            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(1500));

            downstream.Within(TimeSpan.FromMilliseconds(1000), () =>
            {
                downstream.ExpectNext().ShouldAllBeEquivalentTo(new[] {4});
                return NotUsed.Instance;
            });

            upstream.SendComplete();
            downstream.ExpectComplete();
            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
        }