Пример #1
0
        public void TestPingSupervisor()
        {
            var testResults = new PingActor.PingTestResults();
            var ping        = TestWorld.ActorFor <IPing>(
                Definition.Has <PingActor>(
                    Definition.Parameters(testResults), "ping"));

            var supervisorResults = PingSupervisorActor.Instance.Value.TestResults;
            var pingAccess        = testResults.AfterCompleting(5);
            var supervisorAccess  = supervisorResults.AfterCompleting(5);


            for (var idx = 0; idx < 5; ++idx)
            {
                ping.Actor.Ping();
            }

            Assert.False(ping.ActorInside.IsStopped);
            Assert.Equal(5, pingAccess.ReadFrom <int>("pingCount"));
            Assert.Equal(5, supervisorAccess.ReadFrom <int>("informedCount"));

            pingAccess = testResults.AfterCompleting(2);

            ping.Actor.Ping();

            Assert.Equal(6, pingAccess.ReadFrom <int>("pingCount"));
            Assert.Equal(6, supervisorAccess.ReadFrom <int>("informedCount"));

            Assert.True(ping.ActorInside.IsStopped);
        }
Пример #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"));
        }
Пример #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);
        }
Пример #4
0
        public void TestPingSupervisor()
        {
            var testResults = new PingActor.PingTestResults();
            var ping        = TestWorld.ActorFor <IPing>(
                Definition.Has <PingActor>(
                    Definition.Parameters(testResults), "ping"));

            testResults.UntilPinged = Until(5);

            for (var idx = 0; idx < 5; ++idx)
            {
                PingSupervisorActor.Instance.Value.TestResults.UntilInform = Until(1);
                ping.Actor.Ping();
                PingSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();
            }

            testResults.UntilPinged.Completes();
            // PingSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();

            Assert.False(ping.ActorInside.IsStopped);
            Assert.Equal(5, testResults.PingCount.Get());
            Assert.Equal(5, PingSupervisorActor.Instance.Value.TestResults.InformedCount.Get());

            testResults.UntilPinged  = Until(1);
            testResults.UntilStopped = Until(1);
            PingSupervisorActor.Instance.Value.TestResults.UntilInform = Until(1);

            ping.Actor.Ping();

            PingSupervisorActor.Instance.Value.TestResults.UntilInform.Completes();
            testResults.UntilPinged.Completes();
            testResults.UntilStopped.Completes();

            Assert.True(ping.ActorInside.IsStopped);
            Assert.Equal(6, testResults.PingCount.Get());
            Assert.Equal(6, PingSupervisorActor.Instance.Value.TestResults.InformedCount.Get());
        }