Example #1
0
        public void SwitchToPlaylist_PlaySongThenChangePlaylist_NextSongDoesNotPlayWhenSongFinishes()
        {
            using (Library library = Helpers.CreateLibraryWithPlaylist())
            {
                var handle = new ManualResetEvent(false);

                var player = new HandledAudioPlayer(handle);

                var song = new Mock <Song>("TestPath", AudioType.Mp3, TimeSpan.Zero);
                song.Setup(p => p.CreateAudioPlayer()).Returns(player);

                bool played = false;

                var notPlayedSong = new Mock <Song>("TestPath2", AudioType.Mp3, TimeSpan.Zero);
                notPlayedSong.Setup(p => p.CreateAudioPlayer())
                .Returns(new Mock <AudioPlayer>().Object)
                .Callback(() => played = true);

                library.AddSongToPlaylist(song.Object);
                library.PlaySong(0);

                library.AddAndSwitchToPlaylist("Playlist2");

                handle.Set();

                Assert.IsFalse(played);
            }
        }
Example #2
0
        public void SwitchToPlaylist_PlaySongThenChangePlaylist_NextSongDoesNotPlayWhenSongFinishes()
        {
            using (Library library = Helpers.CreateLibraryWithPlaylist())
            {
                var handle = new ManualResetEvent(false);

                var player = new HandledAudioPlayer(handle);

                var song = new Mock<Song>("TestPath", AudioType.Mp3, TimeSpan.Zero);
                song.Setup(p => p.CreateAudioPlayer()).Returns(player);

                bool played = false;

                var notPlayedSong = new Mock<Song>("TestPath2", AudioType.Mp3, TimeSpan.Zero);
                notPlayedSong.Setup(p => p.CreateAudioPlayer())
                    .Returns(new Mock<AudioPlayer>().Object)
                    .Callback(() => played = true);

                library.AddSongToPlaylist(song.Object);
                library.PlaySong(0);

                library.AddAndSwitchToPlaylist("Playlist2");

                handle.Set();

                Assert.IsFalse(played);
            }
        }