Akka.Remote.Tests.MultiNode.Router.RemoteRoundRobinSpec.A_remote_round_robin_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_remote_actor_ref C# (CSharp) Method

A_remote_round_robin_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_remote_actor_ref() public method

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

            var runOnFourth = new Action(() =>
            {
                EnterBarrier("start");
                var actor = Sys.ActorOf(new RoundRobinPool(nrOfInstances: 0)
                    .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 =>
                {
                    if (x is IActorRef) return x.AsInstanceOf<IActorRef>().Path.Address;
                    return 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");
                Log.Debug("Counts for RemoteRoundRobinSpec nodes. First: {0}, Second: {1}, Third: {2}", replies[Node(_config.First).Address],
                   replies[Node(_config.Second).Address], replies[Node(_config.Third).Address]);
                replies.Values.ForEach(x => Assert.Equal(x, iterationCount));
                Assert.False(replies.ContainsKey(Node(_config.Fourth).Address));

                Sys.Stop(actor);
            });

            RunOn(runOnFourth, _config.Fourth);
            EnterBarrier("done");
        }