コード例 #1
0
        public void dispatch_events_to_single_player(bool isPlaying, JukeboxCommand cmd)
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(isPlaying);
            EventDispatcher dsp = new EventDispatcher(new[]{itunes.Object});

            dsp.Dispatch(cmd);

            itunes.Verify(m => m.PerformAction(cmd));
        }
コード例 #2
0
        public void dispatch_events_to_single_of_multiple_players(JukeboxCommand cmd)
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(false);
            superplayer.SetupGet(m => m.IsPlaying).Returns(false);
            spotify.SetupGet(m => m.IsPlaying).Returns(true);
            EventDispatcher dsp = new EventDispatcher(new[] { itunes.Object, spotify.Object, superplayer.Object });

            dsp.Dispatch(cmd);

            superplayer.Verify(m => m.PerformAction(cmd), Times.Never());
            itunes.Verify(m => m.PerformAction(cmd), Times.Never());
            spotify.Verify(m => m.PerformAction(cmd), Times.Once());
        }
コード例 #3
0
        public void event_may_not_be_dispatched_to_and_inactive_playing_player()
        {
            var cmd = JukeboxCommand.Play;
            itunes.SetupGet(m => m.IsPlaying).Returns(false);
            superplayer.SetupGet(m => m.IsPlaying).Returns(false);
            spotify.SetupGet(m => m.IsPlaying).Returns(true);
            itunes.SetupGet(m => m.IsAvailable).Returns(false);
            superplayer.SetupGet(m => m.IsAvailable).Returns(false);
            spotify.SetupGet(m => m.IsAvailable).Returns(false);

            EventDispatcher dsp = new EventDispatcher(new[] { itunes.Object, spotify.Object, superplayer.Object });

            dsp.Dispatch(cmd);

            superplayer.Verify(m => m.PerformAction(cmd), Times.Never());
            itunes.Verify(m => m.PerformAction(cmd), Times.Never());
            spotify.Verify(m => m.PerformAction(cmd), Times.Never());
        }
コード例 #4
0
        public void uses_last_jukebox_only_if_still_available()
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(true);
            EventDispatcher dsp1 = new EventDispatcher(new[] { itunes.Object, spotify.Object });

            dsp1.Dispatch(JukeboxCommand.Pause);

            itunes.SetupGet(m => m.IsPlaying).Returns(false);
            itunes.SetupGet(m => m.IsAvailable).Returns(false);

            dsp1.Dispatch(JukeboxCommand.Play);

            itunes.Verify(m => m.PerformAction(JukeboxCommand.Pause), Times.Once());
            spotify.Verify(m => m.PerformAction(JukeboxCommand.Play), Times.Once());
        }
コード例 #5
0
        public void send_event_to_last_player_if_unsure()
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(false);
            superplayer.SetupGet(m => m.IsPlaying).Returns(false);
            spotify.SetupGet(m => m.IsPlaying).Returns(true);

            EventDispatcher dsp = new EventDispatcher(new[] { itunes.Object, spotify.Object, superplayer.Object });

            dsp.Dispatch(JukeboxCommand.Pause);
            spotify.SetupGet(m => m.IsPlaying).Returns(false);

            dsp.Dispatch(JukeboxCommand.Play);

            superplayer.Verify(m => m.PerformAction(It.IsAny<JukeboxCommand>()), Times.Never());
            itunes.Verify(m => m.PerformAction(It.IsAny<JukeboxCommand>()), Times.Never());
            spotify.Verify(m => m.PerformAction(It.IsAny<JukeboxCommand>()), Times.Exactly(2));
        }
コード例 #6
0
        public void ignores_inactive_jukeboxes()
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(true);
            itunes.SetupGet(m => m.IsActive).Returns(false);
            EventDispatcher dsp1 = new EventDispatcher(new[] { itunes.Object });

            dsp1.Dispatch(JukeboxCommand.Pause);
            dsp1.Dispatch(JukeboxCommand.Play);
            dsp1.Dispatch(JukeboxCommand.NextTrack);
            itunes.Verify(m => m.PerformAction(It.IsAny<JukeboxCommand>()), Times.Never());
        }
コード例 #7
0
        public void handles_play_after_paused_logic_start_playing()
        {
            itunes.SetupGet(m => m.IsPlaying).Returns(true);
            EventDispatcher dsp1 = new EventDispatcher(new[] { itunes.Object });

            dsp1.Dispatch(JukeboxCommand.Pause);
            itunes.SetupGet(m => m.IsPlaying).Returns(false);
            dsp1.Dispatch(JukeboxCommand.PlayAfterPaused);
            itunes.Verify(m => m.PerformAction(JukeboxCommand.Play), Times.Once());
        }
コード例 #8
0
        public void handles_play_after_paused_logic_keep_quite()
        {
            spotify.SetupGet(m => m.IsPlaying).Returns(false);
            EventDispatcher dsp1 = new EventDispatcher(new[] { spotify.Object });

            dsp1.Dispatch(JukeboxCommand.Pause);
            spotify.SetupGet(m => m.IsPlaying).Returns(false);
            dsp1.Dispatch(JukeboxCommand.PlayAfterPaused);
            spotify.Verify(m => m.PerformAction(JukeboxCommand.Play), Times.Never());
        }