public void UniqueNameDoesValidate()
            {
                using (Library library = new LibraryBuilder().Build())
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();
                    library.AddPlaylist("Existing", accessToken);
                    library.AddPlaylist("New", accessToken);

                    var fixture = new PlaylistViewModel(library.Playlists.Single(x => x.Name == "New"), library, accessToken, new CoreSettings());

                    fixture.EditName = true;
                    fixture.Name = "Unique";

                    Assert.Null(fixture["Name"]);
                }
            }
예제 #2
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));
                }
            }
예제 #3
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);
                }
            }
예제 #4
0
            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);
                }
            }