Exemplo n.º 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);
        }
Exemplo n.º 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"));
        }
Exemplo n.º 3
0
        public void TestStopAll()
        {
            World.ActorFor <ISupervisor>(Definition.Has <StopAllSupervisorActor>(Definition.NoParameters, "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"));

            pingTestResults.UntilStopped = Until(1);
            pongTestResults.UntilStopped = Until(1);

            Assert.False(PingActor.Instance.Value.IsStopped);
            Assert.False(PongActor.Instance.Value.IsStopped);

            ping.Ping();
            pingTestResults.UntilStopped.Completes();
            pongTestResults.UntilStopped.Completes();

            Assert.True(PingActor.Instance.Value.IsStopped);
            Assert.True(PongActor.Instance.Value.IsStopped);
        }
Exemplo n.º 4
0
        public void TestPongSupervisor()
        {
            var testResults = new PongActor.PongTestResults();
            var pong        = TestWorld.ActorFor <IPong>(
                Definition.Has <PongActor>(
                    Definition.Parameters(testResults), "pong"));

            testResults.UntilPonged = Until(5);

            for (var idx = 0; idx < 10; ++idx)
            {
                PongSupervisorActor.Instance.Value.TestResults.UntilInform = Until(1);
                pong.Actor.Pong();
                PongSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();
            }

            testResults.UntilPonged.Completes();
            // PongSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();

            Assert.False(pong.ActorInside.IsStopped);
            Assert.Equal(10, testResults.PongCount.Get());
            Assert.Equal(10, PongSupervisorActor.Instance.Value.TestResults.InformedCount.Get());

            testResults.UntilPonged  = Until(1);
            testResults.UntilStopped = Until(1);
            PongSupervisorActor.Instance.Value.TestResults.UntilInform = Until(1);

            pong.Actor.Pong();

            PongSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();
            testResults.UntilPonged.Completes();
            testResults.UntilStopped.Completes();

            Assert.True(pong.ActorInside.IsStopped);
            Assert.Equal(11, testResults.PongCount.Get());
            Assert.Equal(11, PongSupervisorActor.Instance.Value.TestResults.InformedCount.Get());
        }