Пример #1
0
        public async Task GetInterfacedPoisonPill_WaitForAllReentrantHandlersDone()
        {
            // Arrange
            var log = new LogBoard <string>();
            var a   = ActorOf(() => new TestGracefulShutdownActor(log)).Cast <WorkerRef>();

            // Act
            a.WithNoReply().Reentrant(1);
            a.WithNoReply().Reentrant(2);
            await a.CastToIActorRef().GracefulStop(TimeSpan.FromMinutes(1), InterfacedPoisonPill.Instance);

            // Assert
            Assert.True(new HashSet <string>
            {
                "Reentrant(1)",
                "Reentrant(1) done",
                "Reentrant(2)",
                "Reentrant(2) done",
            }.SetEquals(log.Take(4)));
            Assert.Equal(new List <string>
            {
                "OnGracefulStop",
                "OnGracefulStop done"
            }, log.Skip(4));
        }
Пример #2
0
        public async Task TaskRun_AtomicAsyncHandler_ExecutedInterleaved()
        {
            // Arrange
            var log   = new LogBoard <string>();
            var actor = ActorOf(() => new TestRunActor(log));

            // Act
            actor.Tell("R:1");
            actor.Tell("R:2");
            await actor.GracefulStop(TimeSpan.FromMinutes(1), "X");

            // Assert
            Assert.Equal(new[] { "R:1", "R:2" },
                         log.Take(2));
            Assert.Equal(new[] { "R:1 done", "R:2 done" },
                         log.Skip(2).OrderBy(x => x));
        }
Пример #3
0
        public async Task Message_AtomicAsyncHandler_ExecutedInterleaved()
        {
            // Arrange
            var log   = new LogBoard <string>();
            var actor = ActorOf(() => new TestMessageActor(log));

            // Act
            actor.Tell(new PlainMessages.TaskReentrant {
                Value = "A"
            });
            actor.Tell(new PlainMessages.TaskReentrant {
                Value = "B"
            });
            await actor.GracefulStop(TimeSpan.FromMinutes(1), InterfacedPoisonPill.Instance);

            // Assert
            Assert.Equal(new[] { "A_1", "B_1" },
                         log.Take(2));
            Assert.Equal(new[] { "A_2", "B_2" },
                         log.Skip(2).OrderBy(x => x));
        }
        public async Task FilterPerInstanceMethod_Work()
        {
            // Arrange
            var log = new LogBoard <string>();
            var a   = ActorOf(() => new RequestFilterPerInstanceMethodActor(log)).Cast <DummyExRef>();

            // Act
            await a.Call("A");

            await a.Call("B");

            await a.CallEx("C");

            // Assert
            Assert.Equal(
                new[]
            {
                "RequestFilterPerInstanceMethodActor.Call.Constructor",
                "RequestFilterPerInstanceMethodActor.CallEx.Constructor",
            },
                log.Take(2).OrderBy(x => x));
            Assert.Equal(
                new[]
            {
                "RequestFilterPerInstanceMethodActor.Call.OnPreRequest",
                "Call(A)",
                "RequestFilterPerInstanceMethodActor.Call.OnPostRequest",
                "RequestFilterPerInstanceMethodActor.Call.OnPreRequest",
                "Call(B)",
                "RequestFilterPerInstanceMethodActor.Call.OnPostRequest",
                "RequestFilterPerInstanceMethodActor.CallEx.OnPreRequest",
                "CallEx(C)",
                "RequestFilterPerInstanceMethodActor.CallEx.OnPostRequest"
            },
                log.Skip(2));
        }