Akka.Remote.Tests.MultiNode.Router.RemoteScatterGatherSpec.A_remote_ScatterGatherFirstCompleted_pool_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_RemoteActorRef C# (CSharp) Method

A_remote_ScatterGatherFirstCompleted_pool_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_RemoteActorRef() private method

        public void A_remote_ScatterGatherFirstCompleted_pool_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_RemoteActorRef()
        {
            var mute = new Mute(new WarningFilter(new RegexMatcher(new Regex(".*Received dead letter from.*"))));
            Sys.EventStream.Publish(mute);

            RunOn(() => EnterBarrier("start", "broadcast-end", "end", "done"), 
                _config.First, _config.Second,_config.Third);

            RunOn(() =>
            {
                EnterBarrier("start");
                var actor =
                    Sys.ActorOf(new ScatterGatherFirstCompletedPool(nrOfInstances: 1, within: TimeSpan.FromSeconds(10))
                        .Props(Props.Create<SomeActor>()), "service-hello");
                
                Assert.IsType<RoutedActorRef>(actor);
                
                var connectionCount = 3;
                var iterationCount = 10;

                for (var i = 0; i < iterationCount; i++)
                    for (var k = 0; k < connectionCount; k++)
                        actor.Tell("hit");

                var replies = ReceiveWhile(TimeSpan.FromSeconds(5),
                    x => x is IActorRef ? x.AsInstanceOf<IActorRef>().Path.Address : null,
                    connectionCount*iterationCount)
                    .Aggregate(ImmutableDictionary<Address, int>.Empty
                        .Add(Node(_config.First).Address, 0)
                        .Add(Node(_config.Second).Address, 0)
                        .Add(Node(_config.Third).Address, 0),
                        (map, address) =>
                        {
                            var previous = map[address];
                            return map.Remove(address).Add(address, previous + 1);
                        });

                EnterBarrier("broadcast-end");
                actor.Tell(new Broadcast(PoisonPill.Instance));

                EnterBarrier("end");
                replies.Values.Sum().ShouldBe(30);
                replies.ContainsKey(Node(_config.Fourth).Address).ShouldBeFalse();
                
                // shut down the actor before we let the other node(s) shut down so we don't try to send
                // "Terminate" to a shut down node
                Sys.Stop(actor);
                EnterBarrier("done");
            }, _config.Fourth);

            EnterBarrier("done");
        }
    }