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