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); }
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)); }
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); }