Akka.Remote.Tests.MultiNode.Router.RemoteRoundRobinSpec.A_remote_round_robin_pool_with_resizer_must_be_locally_instantiated_on_a_remote_node_after_several_resize_rounds C# (CSharp) Метод

A_remote_round_robin_pool_with_resizer_must_be_locally_instantiated_on_a_remote_node_after_several_resize_rounds() публичный Метод

        public void A_remote_round_robin_pool_with_resizer_must_be_locally_instantiated_on_a_remote_node_after_several_resize_rounds()
        {
            Within(TimeSpan.FromSeconds(10), () =>
            {
                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: 1,
                        resizer: new TestResizer()
                        ).Props(Props.Create<SomeActor>()), "service-hello2");

                    Assert.IsType<RoutedActorRef>(actor);

                    actor.Tell(RouterMessage.GetRoutees);
                    ExpectMsg<Routees>().Members.Count().ShouldBe(2);

                    var repliesFrom = Enumerable.Range(3, 7).Select(n =>
                    {
                        //each message triggers a resize, incrementing number of routees with 1
                        actor.Tell("hit");
                        var routees = actor.AskAndWait<Routees>(RouterMessage.GetRoutees, TimeSpan.FromSeconds(5));
                        routees.Members.Count().ShouldBe(n);
                        return ExpectMsg<IActorRef>();
                    }).ToImmutableHashSet();

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

                    EnterBarrier("end");
                    Assert.Equal(repliesFrom.Count, 7);
                    var repliesFromAddresses = repliesFrom.Select(x => x.Path.Address).Distinct();
                    var expectedAddresses = new List<ActorPath>
                    {
                        Node(_config.First),
                        Node(_config.Second),
                        Node(_config.Third)
                    }
                        .Select(x => x.Address);

                    // check if they have same elements (ignoring order)
                    Assert.All(repliesFromAddresses, x => Assert.Contains(x, expectedAddresses));
                    Assert.True(repliesFromAddresses.Count() == expectedAddresses.Count());

                    Sys.Stop(actor);
                });

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