public async Task NullYoutubeSongFinderResultDoesNothing()
            {
                var songFinder = Substitute.For<IYoutubeSongFinder>();
                songFinder.ResolveYoutubeSongFromUrl(Arg.Any<Uri>()).Returns(Task.FromResult<YoutubeSong>(null));

                using (var library = new LibraryBuilder().WithPlaylist().Build())
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();

                    var playlist = library.Playlists.First();
                    library.SwitchToPlaylist(playlist, accessToken);

                    var fixture = new DirectYoutubeViewModel(library, accessToken, songFinder);

                    await fixture.AddDirectYoutubeUrlToPlaylist(new Uri("http://youtube.com?v=yadda"), null);

                    Assert.Equal(0, playlist.Count());
                }
            }
            public async Task NullUriThrowsArgumentNullException()
            {
                const string youtubePath = "http://youtube.com?v=yadda";
                var song = new YoutubeSong(youtubePath, TimeSpan.FromMinutes(1));
                var songFinder = Substitute.For<IYoutubeSongFinder>();
                songFinder.ResolveYoutubeSongFromUrl(Arg.Any<Uri>()).Returns(Task.FromResult(song));

                using (var library = new LibraryBuilder().WithPlaylist().Build())
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();

                    var playlist = library.Playlists.First();
                    library.SwitchToPlaylist(playlist, accessToken);

                    var fixture = new DirectYoutubeViewModel(library, accessToken, songFinder);

                    await Helpers.ThrowsAsync<ArgumentNullException>(() => fixture.AddDirectYoutubeUrlToPlaylist(null, null));
                }
            }
            public async Task SmokeTest()
            {
                const string youtubePath = "http://youtube.com?v=yadda";
                var song = new YoutubeSong(youtubePath, TimeSpan.FromMinutes(1));
                var songFinder = Substitute.For<IYoutubeSongFinder>();
                songFinder.ResolveYoutubeSongFromUrl(Arg.Any<Uri>()).Returns(Task.FromResult(song));

                using (var library = new LibraryBuilder().WithPlaylist().Build())
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();

                    var playlist = library.Playlists.First();
                    library.SwitchToPlaylist(playlist, accessToken);

                    var fixture = new DirectYoutubeViewModel(library, accessToken, songFinder);

                    await fixture.AddDirectYoutubeUrlToPlaylist(new Uri(youtubePath), null);

                    Assert.Equal(1, playlist.Count());
                }
            }
Exemple #4
0
            public void ThrowsAccessExceptionIfPartyModeAndLockPlaylistSwitchingIsTrue()
            {
                var settings = new CoreSettings
                {
                    LockPlaylist = true
                };

                using (Library library = new LibraryBuilder().WithPlaylist("Playlist 1").WithSettings(settings).Build())
                {
                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.AddPlaylist("Playlist 2", token);

                    library.LocalAccessControl.SetLocalPassword(token, "Password");
                    library.LocalAccessControl.DowngradeLocalAccess(token);

                    Assert.Throws<AccessException>(() => library.SwitchToPlaylist(library.GetPlaylistByName("Playlist 2"), token));
                }
            }
Exemple #5
0
            public async Task SetsCurrentSongIndexIfChangingToOtherPlaylistAndPlayingFirstSong()
            {
                var settings = new CoreSettings
                {
                    EnablePlaylistTimeout = false
                };

                using (Library library = new LibraryBuilder().WithPlaylist().WithSettings(settings).Build())
                {
                    var coll = library.CurrentPlaylistChanged.StartWith(library.CurrentPlaylist)
                        .Select(x => x.WhenAnyValue(y => y.CurrentSongIndex)).Switch().CreateCollection();

                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.AddSongToPlaylist(Helpers.SetupSongMock());

                    await library.PlaySongAsync(0, token);

                    library.AddPlaylist("Playlist 2", token);
                    library.SwitchToPlaylist(library.Playlists.Last(), token);
                    library.AddSongToPlaylist(Helpers.SetupSongMock());

                    await library.PlaySongAsync(0, token);

                    Assert.Equal(new int?[] { null, 0, null, null, 0, null }, coll);
                }
            }
            public async Task SetsCurrentSongIndexIfChangingToOtherPlaylistAndPlayingFirstSong()
            {
                using (Library library = new LibraryBuilder().WithPlaylist().Build())
                {
                    var coll = library.WhenAnyValue(x => x.CurrentPlaylist.CurrentSongIndex).CreateCollection();

                    Guid token = library.LocalAccessControl.RegisterLocalAccessToken();

                    library.AddSongsToPlaylist(new[] { Helpers.SetupSongMock() }, token);

                    await library.PlaySongAsync(0, token);

                    library.AddPlaylist("Playlist 2", token);
                    library.SwitchToPlaylist(library.Playlists.Last(), token);
                    library.AddSongsToPlaylist(new[] { Helpers.SetupSongMock() }, token);

                    await library.PlaySongAsync(0, token);

                    Assert.Equal(new int?[] { null, 0, null, null, 0, null }, coll);
                }
            }