public void GetActualSong()
        {
            SongToPlay song1 = new SongToPlay();
            SongToPlay song2 = new SongToPlay {IsPlaying = true};
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);

            Assert.AreEqual(song2, playList.ActualSong);
        }
        public void GetFirst()
        {
            SongToPlay song1 = new SongToPlay();
            SongToPlay song2 = new SongToPlay();
            SongToPlay song3 = new SongToPlay();
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);
            playList.OriginalSongs.Add(song3);

            Assert.AreEqual(song1, playList.GetFirst());
        }
Ejemplo n.º 3
0
 public virtual void AddSongs(ObservableCollection<Song> songs)
 {
     foreach (Song song in songs)
     {
         if (SongsToPlay.All(stp => stp.Song != song))
         {
             SongToPlay songToPlay = new SongToPlay() { Song = song };
             OriginalSongs.Add(songToPlay);
             SongsToPlay.Add(songToPlay);
         }
     }
 }
        public void WhenASongIsPlayedSetPlayedUnlessActualSongIfNull()
        {
            SongToPlay beforeSong = null;
            SongToPlay afterSong = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.ActualSong).Returns(beforeSong);

            ViewModel.PlaySongCommand.Execute(afterSong);

            Assert.IsTrue(afterSong.IsPlaying);
            Assert.IsTrue(afterSong.Played);
        }
        public void SayIfItTheFirstThatIsPlaying()
        {
            SongToPlay song1 = new SongToPlay(){IsPlaying = true, Played = true};
            SongToPlay song2 = new SongToPlay();
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);

            Assert.IsTrue(playList.PlayingTheFirst);
        }
        public void PlayASong()
        {
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();
            SongToPlay song = new SongToPlay {Song = Create.Song()};

            ViewModel.PlaySongCommand.Execute(song);

            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
            Assert.AreEqual(State.Play, ViewModel.PlayerState);
        }
        public void ReturnIsFinished()
        {
            SongToPlay song1 = new SongToPlay { Played = true };
            SongToPlay song2 = new SongToPlay();
            SongToPlay song3 = new SongToPlay { Played = true};
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);
            playList.SongsToPlay.Add(song3);

            Assert.IsFalse(playList.IsFinished);

            song3.IsPlaying = true;

            Assert.IsTrue(playList.IsFinished);
        }
        public void ReturnNullIfTheyAreNoSongOnPlayingMode()
        {
            SongToPlay song1 = new SongToPlay();
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);

            Assert.IsNull(playList.ActualSong);
        }
        public void GetTheLast()
        {
            SongToPlay song1 = new SongToPlay ();
            SongToPlay song2 = new SongToPlay();
            SongToPlay song3 = new SongToPlay();
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);
            playList.SongsToPlay.Add(song3);

            Assert.AreEqual(song3, playList.GetLast());
        }
        public void ResetAllSongs()
        {
            SongToPlay song1 = new SongToPlay {Played = true};
            SongToPlay song2 = new SongToPlay ();
            SongToPlay song3 = new SongToPlay {Played = true, IsPlaying = true};
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);
            playList.SongsToPlay.Add(song3);

            playList.ResetAllSongs();

            Assert.IsFalse(song1.Played);
            Assert.IsFalse(song2.Played);
            Assert.IsFalse(song3.Played);
            Assert.IsFalse(song1.IsPlaying);
            Assert.IsFalse(song2.IsPlaying);
            Assert.IsFalse(song3.IsPlaying);
        }
        public void GetPreviousSong()
        {
            SongToPlay song1 = new SongToPlay();
            SongToPlay song2 = new SongToPlay { IsPlaying = true };
            SongToPlay song3 = new SongToPlay();
            PlayList playList = new PlayList();
            playList.SongsToPlay.Add(song1);
            playList.SongsToPlay.Add(song2);
            playList.SongsToPlay.Add(song3);

            Assert.AreEqual(song1, playList.GetPreviousSong());
        }
        public void IfPlayListIsTheBeginningAndRepeatIsActivatedPlayTheLastSong()
        {
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();
            SongToPlay song = new SongToPlay();
            ViewModel.PlayerState = State.Play;
            ViewModel.Repeat = true;
            mockPlayList.Setup(pl => pl.PlayingTheFirst).Returns(true);
            mockPlayList.Setup(pl => pl.GetLast()).Returns(song);

            ViewModel.PreviousSongCommand.Execute(null);

            mockPlayList.Verify(pl => pl.ResetAllSongs(), Times.Once());
            mockPlayList.Verify(pl => pl.GetLast(), Times.Once());
            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
            Assert.AreEqual(State.Play, ViewModel.PlayerState);
        }
        public void WhenASongIsPlayedSetPlayedProperties()
        {
            SongToPlay beforeSong = new SongToPlay {Song = Create.Song(), IsPlaying = true, Played = true};
            SongToPlay afterSong = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.ActualSong).Returns(beforeSong);

            ViewModel.PlaySongCommand.Execute(afterSong);

            Assert.IsFalse(beforeSong.IsPlaying);
            Assert.IsTrue(beforeSong.Played);
            Assert.IsTrue(afterSong.IsPlaying);
            Assert.IsTrue(afterSong.Played);
        }
        public void PlayTheFirstSongOfPlayListIfParameterIsNull()
        {
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();
            SongToPlay song = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.GetFirst()).Returns(song);

            ViewModel.PlaySongCommand.Execute(null);

            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
            Assert.AreEqual(State.Play, ViewModel.PlayerState);
        }
        public void PlayPreviousSong()
        {
            SongToPlay song1 = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.GetPreviousSong()).Returns(song1);
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();

            ViewModel.PreviousSongCommand.Execute(null);

            mockPlayList.Verify();
            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song1.Song, eventCatcher.SongToPlay);
        }
        public void PlayNextSongWhenTheCurrentIsFinished()
        {
            SongToPlay song = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.GetNextSong()).Returns(song);
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();

            PlayerObserver.NotifyCurrentSongFinished();

            mockPlayList.Verify(pl => pl.GetNextSong(), Times.Once());
            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
        }
        public void PlayNextSongOfPlayList()
        {
            SongToPlay song = new SongToPlay {Song = Create.Song()};
            mockPlayList.Setup(pl => pl.GetNextSong()).Returns(song);
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();

            ViewModel.NextSongCommand.Execute(null);

            mockPlayList.Verify(pl => pl.GetNextSong(), Times.Once());
            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
        }
 private void RaiseNewPlaySongDemand(SongToPlay song)
 {
     if (!PlayList.IsEmpty)
     {
         SongToPlay songToPlay = song ?? PlayList.GetFirst();
         if (PlayList.ActualSong != null)
         {
             PlayList.ActualSong.IsPlaying = false;
         }
         songToPlay.IsPlaying = true;
         songToPlay.Played = true;
         PlayerObserver.NotifyPlayNewSong(songToPlay.Song);
         PlayerState = State.Play;
     }
 }
        public void IfPlayListIsFinishedAndRepeatIsActivatedPlayTheFirstSong()
        {
            PlayerEventCatcher eventCatcher = new PlayerEventCatcher();
            SongToPlay song = new SongToPlay();
            ViewModel.PlayerState = State.Play;
            ViewModel.Repeat = true;
            mockPlayList.Setup(pl => pl.IsFinished).Returns(true);
            mockPlayList.Setup(pl => pl.GetFirst()).Returns(song);

            PlayerObserver.NotifyCurrentSongFinished();

            mockPlayList.Verify(pl => pl.ResetAllSongs(), Times.Once());
            mockPlayList.Verify(pl => pl.GetFirst(), Times.Once());
            Assert.IsTrue(eventCatcher.PlaySongInvoked);
            Assert.AreEqual(song.Song, eventCatcher.SongToPlay);
            Assert.AreEqual(State.Play, ViewModel.PlayerState);
        }