Ejemplo n.º 1
0
            public async Task PreventsNextSongFromPlaying()
            {
                var audioPlayerCallback = Substitute.For<IMediaPlayerCallback>();

                using (Library library = new LibraryBuilder().WithPlaylist().WithAudioPlayer(audioPlayerCallback).Build())
                {
                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    int played = 0;

                    audioPlayerCallback.PlayAsync().Returns(Task.Run(() =>
                    {
                        if (played == 0)
                        {
                            library.AddAndSwitchToPlaylist("Playlist2", token);
                        }

                        played++;
                    }));

                    library.AddSongsToPlaylist(Helpers.SetupSongMocks(2), token);

                    await library.PlaySongAsync(0, token);

                    Assert.Equal(1, played);
                }
            }
Ejemplo n.º 2
0
            public async Task DoesNotSaveTemporaryPlaylist()
            {
                var libraryWriter = Substitute.For<ILibraryWriter>();

                using (Library library = new LibraryBuilder().WithWriter(libraryWriter).Build())
                {
                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.AddAndSwitchToPlaylist("Playlist", token);

                    await library.PlayInstantlyAsync(Helpers.SetupSongMocks(1), token);

                    library.Save();
                }

                libraryWriter.Received(1).Write(Arg.Any<IEnumerable<LocalSong>>(), Arg.Is<IEnumerable<Playlist>>(x => x.Count() == 1), Arg.Any<string>());
            }