Exemplo n.º 1
0
        public void When_MovePrevious_SongListHasPreviousSongs_ReturnsCorrectSongs()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleNoLoop,
                Playlist = _bigPlaylist
            };

            for (int i = 0; i < _nbSongs; i++)
            {
                songList.MoveNext();
            }

            // Act
            var previousSongs = new List <SongDto>();

            for (int i = 0; i < _nbSongs; i++)
            {
                var song = songList.MovePrevious().CurrentSong;
                previousSongs.Add(song);
            }

            // Assert
            for (int i = 0; i < _nbSongs; i++)
            {
                Assert.AreEqual($"{_songPrefixBig}{_nbSongs - 1 - i}", previousSongs[i].Title);
            }
        }
Exemplo n.º 2
0
        public void When_PlayModeSet_MovePreviousFollowingSongsContainsCorrectSongs()
        {
            // Arrange
            int goBack   = 5;
            var songList = new SongList
            {
                PlayMode = _noShuffleLoopPlaylist,
                Playlist = _bigPlaylist
            };

            for (int i = 0; i < _nbSongs; i++) // play some songs
            {
                songList.MoveNext();
            }
            for (int i = 0; i < goBack; i++) // go back 5 songs
            {
                songList.MovePrevious();
            }

            // Act
            songList.PlayMode = _noShuffleNoLoop;
            var songs = songList.GetFollowingSongs(_queueSize);

            // Assert
            for (int i = _nbSongs - goBack; i < _nbSongs; i++)
            {
                Assert.AreEqual($"{_songPrefixBig}{i}", songs[i - (_nbSongs - goBack)].Title);
            }
        }
Exemplo n.º 3
0
        public void When_CurrentSongGet_HasFollowingSongs_MovePreviousReturnsCorrectSong()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleLoopPlaylist,
                Playlist = _smallPlaylist
            };

            // Act
            var expected = songList.MoveNext().CurrentSong;

            songList.MoveNext();
            var actual = songList.MovePrevious().CurrentSong;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void When_CurrentSong_PlayedLastSong_MoveNextReturnsNull()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleNoLoop,
                Playlist = _smallPlaylist
            };

            // Act
            for (int i = 0; i < _nbLessSongs; i++)
            {
                songList.MoveNext();
            }
            var actual = songList.MoveNext().CurrentSong;

            // Assert
            Assert.AreEqual(null, actual);
        }
Exemplo n.º 5
0
        public void When_CurrentSong_HasNoFollowingSongs_MoveNextReturnsCorrectSong()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleLoopPlaylist,
                Playlist = _smallPlaylist
            };
            var expected = _smallPlaylist.Songs[1];

            // Act
            for (int i = 0; i < _nbLessSongs; i++)
            {
                songList.MoveNext();
            }
            var actual = songList.MoveNext().CurrentSong;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 6
0
        public void When_MoveNext_PlayModeIsNoLoop_SongAtLoopEndIsNull()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleNoLoop,
                Playlist = _smallPlaylist
            };

            for (int i = 0; i < _nbLessSongs; i++)
            {
                songList.MoveNext();
            }

            // Act
            var song = songList.MoveNext().CurrentSong;

            // Assert
            Assert.IsNull(song);
        }
Exemplo n.º 7
0
        public void When_MoveNextAndPlaylistSet_FollowingSongsContainsCorrectSongs()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleLoopPlaylist,
                Playlist = _bigPlaylist
            };

            // Act
            songList.MoveNext();
            songList.Playlist = _smallPlaylist;
            var songs = songList.GetFollowingSongs(_queueSize);

            // Assert
            for (int i = 0; i < _queueSize; i++)
            {
                Assert.AreEqual($"{_songPrefixSmall}{i % _nbLessSongs}", songs[i].Title);
            }
        }
Exemplo n.º 8
0
        public void When_MoveNext_SongListHasFollowingSongs_ReturnsCorrectSongs()
        {
            // Arrange
            var songList = new SongList
            {
                PlayMode = _noShuffleLoopPlaylist,
                Playlist = _bigPlaylist
            };

            // Act
            var songsPlayed = new List <SongDto>();

            for (int i = 0; i < _nbSongs * 2; i++)
            {
                songsPlayed.Add(songList.CurrentSong);
                songList.MoveNext();
            }

            // Assert
            for (int i = 0; i < _nbSongs; i++)
            {
                Assert.AreEqual($"{_songPrefixBig}{i % _nbSongs}", songsPlayed[i].Title);
            }
        }