Example #1
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>());
            }
Example #2
0
            public void RetriesThreeTimesBeforeGivingUp()
            {
                var libraryWriter = Substitute.For<ILibraryWriter>();
                libraryWriter.When(x => x.Write(Arg.Any<IEnumerable<LocalSong>>(), Arg.Any<IEnumerable<Playlist>>(), Arg.Any<string>()))
                    .Do(x => { throw new LibraryWriteException("Yadda", null); });

                using (Library library = new LibraryBuilder().WithWriter(libraryWriter).Build())
                {
                    library.Save();
                }

                libraryWriter.ReceivedWithAnyArgs(3).Write(Arg.Any<IEnumerable<LocalSong>>(), Arg.Any<IEnumerable<Playlist>>(), Arg.Any<string>());
            }