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>()); }
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>()); }