Пример #1
0
        public void Tail_chopping_router_must_return_response_from_second_actor_after_inactivity_from_first_one()
        {
            var actor1 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(1000)), "Actor3");
            var actor2 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(100)), "Actor4");

            var probe       = CreateTestProbe();
            var routedActor = Sys.ActorOf(Props.Create <TestActor>()
                                          .WithRouter(new TailChoppingGroup(new string[] { actor1.Path.ToString(), actor2.Path.ToString() }, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(50))
                                                      ));

            probe.Send(routedActor, "");
            probe.ExpectMsg("ack");

            var actorList = new List <IActorRef> {
                actor1, actor2
            };

            Assert.True(OneOfShouldEqual(1, actorList)((x => (int)x.Ask("times").Result)));

            routedActor.Tell(new Broadcast("stop"));
        }
Пример #2
0
        public void Tail_chopping_group_router_must_return_response_from_second_actor_after_inactivity_from_first_one()
        {
            var actor1 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(1.Milliseconds())), "Actor1");
            var actor2 = Sys.ActorOf(Props.Create(() => new TailChopTestActor(1.Milliseconds())), "Actor2");

            var probe = CreateTestProbe();
            var paths = new List <string> {
                actor1.Path.ToString(), actor2.Path.ToString()
            };
            var routedActor = Sys.ActorOf(new TailChoppingGroup(paths, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(50)).Props());

            probe.Send(routedActor, "");
            probe.ExpectMsg("ack");

            var actorList = new List <IActorRef> {
                actor1, actor2
            };

            OneOfShouldEqual(1, actorList)(x => (int)x.Ask("times").Result).Should().BeTrue();

            routedActor.Tell(new Broadcast("stop"));
        }