Пример #1
0
        public void PlayerCanGoBack()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song1 = new MusicInfo()
            {
                FullPath = "song1"
            };
            var song2 = new MusicInfo()
            {
                FullPath = "song2"
            };

            playlist.Enqueue(song1);
            playlist.Enqueue(song2);

            player.MaxPlayCount = 2;
            player.Play();

            Assert.AreEqual(1, playlist.CurrentPosition, "The song must have moved one song ahead.");

            player.Back();

            Assert.AreEqual(0, playlist.CurrentPosition, "The song must have moved one song back.");
        }
Пример #2
0
        public void PlayerShouldPlayTheNextSongWhenTheSongFinishes()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song1  = "song1";
            var song2  = "song2";
            var music1 = new MusicInfo()
            {
                FullPath = song1
            };
            var music2 = new MusicInfo()
            {
                FullPath = song2
            };

            playlist.Enqueue(music1);
            playlist.Enqueue(music2);

            player.Play();

            Assert.AreEqual(2, dummyAudio.PlayHistory.Count, "There must be two songs that were played.");
            Assert.AreEqual(song1, dummyAudio.PlayHistory[0], "The first song that was played must be the right one.");
            Assert.AreEqual(song2, dummyAudio.PlayHistory[1], "The second song that was played must be the right one.");
        }
Пример #3
0
        public void PlaylistsCanGoBack()
        {
            string filename1 = "song1";
            string filename2 = "song1";
            var    music1    = new MusicInfo()
            {
                FullPath = filename1
            };
            var music2 = new MusicInfo()
            {
                FullPath = filename2
            };
            var dummyPlaylistWatcher = new DummyPlaylistWatcher();
            var playlist             = new Playlist(dummyPlaylistWatcher);

            playlist.Enqueue(music1);
            playlist.Enqueue(music2);

            Assert.AreEqual(2, playlist.Count, "There must be two songs in the playlist.");

            MusicInfo song = playlist.CurrentSong;

            Assert.AreEqual(filename1, song.FullPath, "The first item in the playlist must be correct.");

            playlist.MoveToNextSong();

            MusicInfo nextSong = playlist.CurrentSong;

            Assert.AreEqual(filename2, nextSong.FullPath, "The second item in the playlist must be correct.");

            playlist.MoveBackOneSong();
            Assert.AreEqual(filename1, playlist.CurrentSong.FullPath, "Going back one song should go back to the first one.");
        }
Пример #4
0
        public void ResumingWhileNotPausedDoesNothing()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song  = "song1";
            var music = new MusicInfo()
            {
                FullPath = song
            };

            playlist.Enqueue(music);

            player.Play();
            player.Resume();

            Assert.IsFalse(dummyAudio.WasResumed, "It should not resume if it wasn't paused.");
        }
Пример #5
0
        public void PlayerShouldStopIfThePlaylistRunsOut()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song  = "song1";
            var music = new MusicInfo()
            {
                FullPath = song
            };

            playlist.Enqueue(music);

            player.Play();

            Assert.AreEqual(1, dummyAudio.PlayHistory.Count, "There must be one song that was played.");
            Assert.AreEqual(song, dummyAudio.PlayHistory[0], "The song that was played must be the right one.");
        }
Пример #6
0
        public void PlayerShouldBeStoppable()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song  = "song1";
            var music = new MusicInfo()
            {
                FullPath = song
            };

            playlist.Enqueue(music);


            player.Play();
            player.Stop();

            Assert.IsTrue(dummyAudio.WasStopped, "It should stop.");
        }
Пример #7
0
        public void PlayerShouldBePausableAndResumeable()
        {
            var playlist   = new Playlist(new DummyPlaylistWatcher());
            var dummyAudio = new DummyAudioInteractor();
            var player     = new Player(playlist, dummyAudio, null);

            var song  = "song1";
            var music = new MusicInfo()
            {
                FullPath = song
            };

            playlist.Enqueue(music);

            player.Play();
            player.Pause();
            player.Resume();

            Assert.IsTrue(dummyAudio.WasPaused, "The audio must have been paused.");
            Assert.IsTrue(dummyAudio.WasResumed, "The audio must have been resumed.");
        }
Пример #8
0
        public void SimpleStart()
        {
            string filename = "song1";
            var    music    = new MusicInfo()
            {
                FullPath = filename
            };
            var dummyPlaylistWatcher = new DummyPlaylistWatcher();
            var playlist             = new Playlist(dummyPlaylistWatcher);

            playlist.Enqueue(music);

            Assert.AreEqual(1, playlist.Count, "There must be one song in the playlist.");

            MusicInfo song = playlist.CurrentSong;

            playlist.CurrentSongIsStarting();

            Assert.AreEqual(filename, song.FullPath, "The next song must be the one that was enqueued.");
            Assert.AreEqual(1, dummyPlaylistWatcher.PlayHistory.Count, "Only one song must have been played.");
            Assert.AreEqual(filename, dummyPlaylistWatcher.PlayHistory[0], "The song that played was ");
        }