Exemple #1
0
        public void TestPongSupervisor()
        {
            var testResults = new PongActor.PongTestResults();
            var pong        = TestWorld.ActorFor <IPong>(
                Definition.Has <PongActor>(
                    Definition.Parameters(testResults), "pong"));

            var supervisorResults = PongSupervisorActor.Instance.Value.TestResults;
            var pongAccess        = testResults.AfterCompleting(10);
            var supervisorAccess  = supervisorResults.AfterCompleting(10);

            for (var idx = 0; idx < 10; ++idx)
            {
                pong.Actor.Pong();
            }

            Assert.Equal(10, pongAccess.ReadFrom <int>("pongCount"));
            Assert.Equal(10, supervisorAccess.ReadFrom <int>("informedCount"));

            Assert.False(pong.ActorInside.IsStopped);

            pongAccess = testResults.AfterCompleting(2);

            pong.Actor.Pong();

            Assert.Equal(11, pongAccess.ReadFrom <int>("pongCount"));
            Assert.Equal(11, supervisorAccess.ReadFrom <int>("informedCount"));

            Assert.True(pong.ActorInside.IsStopped);
        }
Exemple #2
0
        public void TestStopAll()
        {
            var stopResults = new StopAllSupervisorResult();

            World.ActorFor <ISupervisor>(Definition.Has <StopAllSupervisorActor>(Definition.Parameters(stopResults), "stop-all"));

            var pingTestResults = new PingActor.PingTestResults();
            var ping            = World.ActorFor <IPing>(
                Definition.Has <PingActor>(
                    Definition.Parameters(pingTestResults), StopAllSupervisorActor.Instance.Value, "ping"));
            var pongTestResults = new PongActor.PongTestResults();
            var pong            = World.ActorFor <IPong>(
                Definition.Has <PongActor>(
                    Definition.Parameters(pongTestResults), StopAllSupervisorActor.Instance.Value, "pong"));

            var pingAccess = pingTestResults.AfterCompleting(1);
            var pongAccess = pongTestResults.AfterCompleting(1);
            var stopAccess = stopResults.AfterCompleting(1);

            ping.Ping();

            Assert.Equal(1, stopAccess.ReadFrom <int>("informedCount"));
            Assert.Equal(1, pingAccess.ReadFrom <int>("stopCount"));
            Assert.Equal(1, pongAccess.ReadFrom <int>("stopCount"));
        }