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

A_remote_round_robin_group_must_send_messages_with_actor_selection_to_remote_paths() public method

        public void A_remote_round_robin_group_must_send_messages_with_actor_selection_to_remote_paths()
        {
            RunOn(() =>
            {
                Sys.ActorOf<SomeActor>(name: "target-" + Myself.Name);
                EnterBarrier("start", "end");
            }, _config.First, _config.Second, _config.Third);

            var runOnFourth = new Action(() =>
            {
                EnterBarrier("start");
                var actor = Sys.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "service-hello3");

                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("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.ForEach(x => Assert.True(x.Value == iterationCount, $"Expected {x.Key} to have {iterationCount} replies but instead had {x.Value}"));
                Assert.False(replies.ContainsKey(Node(_config.Fourth).Address));
            });

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