コード例 #1
0
        public void ShouldIncreaseSongByOneViaActorSystem()
        {
            TestActorRef <SongPerformanceActor> actor = ActorOfAsTestActorRef <SongPerformanceActor>();

            var songMessage = new PlaySongMessage("Bohemian Rapsody", "John");

            actor.Tell(songMessage);

            Assert.True(actor.UnderlyingActor.SongPeformanceCounter[songMessage.Song] == 1);
        }
コード例 #2
0
        public void IncreaseSongCounter(PlaySongMessage m)
        {
            var counter = 1;

            if (SongPeformanceCounter.ContainsKey(m.Song))
            {
                counter = SongPeformanceCounter[m.Song]++;
            }
            else
            {
                SongPeformanceCounter.Add(m.Song, counter);
            }

            Sender.Tell(new CounterIncreasedMessage(m.Song, counter));
        }
コード例 #3
0
        public void ShouldResendCounterIncreasedMessage()
        {
            TestActorRef <SongPerformanceActor> actor = ActorOfAsTestActorRef <SongPerformanceActor>();

            var songMessage = new PlaySongMessage("Bohemian Rapsody", "John");

            actor.Tell(songMessage);

            /*
             * specify the actor explicitly
             * CounterIncreasedMessage replyMessage = ExpectMsgFrom<CounterIncreasedMessage>(actor);
             */

            CounterIncreasedMessage counter = ExpectMsg <CounterIncreasedMessage>(TimeSpan.FromSeconds(5));

            Assert.That(counter.Song == "Bohemian Rapsody");
            Assert.That(counter.Count == 1);
        }