Akka.Streams.Tests.Dsl.FlowConflateSpec.Conflate_must_restart_when_aggregate_throws_and_a_ResumingDecider_is_used C# (CSharp) Method

Conflate_must_restart_when_aggregate_throws_and_a_ResumingDecider_is_used() private method

        public void Conflate_must_restart_when_aggregate_throws_and_a_ResumingDecider_is_used()
        {
            var sourceProbe = TestPublisher.CreateProbe<int>(this);
            var sinkProbe = TestSubscriber.CreateManualProbe<List<int>>(this);
            var saw4Latch = new TestLatch();

            var graph = Source.FromPublisher(sourceProbe).ConflateWithSeed(i => new List<int> { i },
                (state, elem) =>
                {
                    if (elem == 2)
                        throw new TestException("three is a four letter word");

                    if (elem == 4)
                        saw4Latch.Open();

                    state.Add(elem);
                    return state;
                })
                .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider))
                .To(Sink.FromSubscriber(sinkProbe))
                .WithAttributes(Attributes.CreateInputBuffer(1, 1));
            RunnableGraph.FromGraph(graph).Run(Materializer);

            var sub = sourceProbe.ExpectSubscription();
            var sinkSub = sinkProbe.ExpectSubscription();

            // push the first three values, the third will trigger
            // the exception
            sub.ExpectRequest(1);
            sub.SendNext(1);

            // causing the 1 to get thrown away
            sub.ExpectRequest(1);
            sub.SendNext(2);

            sub.ExpectRequest(1);
            sub.SendNext(3);

            sub.ExpectRequest(1);
            sub.SendNext(4);

            // and consume it, so that the next element
            // will trigger seed
            saw4Latch.Ready(TimeSpan.FromSeconds(3));
            sinkSub.Request(1);

            sinkProbe.ExpectNext().ShouldAllBeEquivalentTo(new [] {1, 3, 4});
        }
    }