コード例 #1
0
 public async Task PlayArtist_ArtistId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayArtist(
         "6FXMGgJwohJLUSr5nVlf9X",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #2
0
 public async Task PlayAlbum_AlbumId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayAlbum(
         "5mAPk4qeNqVLtNydaWbWlf",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #3
0
        public async Task GetDevices_AccessToken_ResultIsNotNull()
        {
            // act
            var result = await new PlayerApi(new HttpClient())
                         .GetDevices(accessToken: await TestsHelper.GetUserAccessToken());

            Assert.IsNotNull(result);
        }
コード例 #4
0
 public async Task PlayTracks_2Tracks_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayTracks(
         new [] { "1vNNfTgHsrpOXeiaXQBlH7", "48rukEbJkzt2yUxAudbcZw" },
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #5
0
 public async Task AddToQueue_ItemUri_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .AddToQueue(
         "spotify:track:6jmVOhtad54Xpx35gMB3qY",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #6
0
 public async Task AddToQueue_ItemUri_Empty_ArgumentNullException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .AddToQueue(
         null,
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #7
0
        public async Task GetPlaylistCoverImage_PlaylistId_AtLeastOnePlalistCoverImageReturnedIsTrue()
        {
            string accessToken = await TestsHelper.GetUserAccessToken();

            var playlistCoverImages = await api.GetPlaylistCoverImage <Image[]>("3cEYpjA9oz9GiPac4AsH4n", accessToken);

            Assert.IsTrue(playlistCoverImages.Length > 0, "No playlist images were found.");
        }
コード例 #8
0
 public async Task PlayPlaylist_PlaylistId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayPlaylist(
         "37i9dQZF1DZ06evO3WBS4o",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #9
0
 public async Task PlayArtistOffset_TrackId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayAlbumOffset(
         "6FXMGgJwohJLUSr5nVlf9X",
         "1vNNfTgHsrpOXeiaXQBlH7",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #10
0
 public async Task PlayAlbumOffset_TrackId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayAlbumOffset(
         "5mAPk4qeNqVLtNydaWbWlf",
         "48rukEbJkzt2yUxAudbcZw",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #11
0
 public async Task PlayPlaylistOffset_TrackId_NoException()
 {
     // act
     await new PlayerApi(new HttpClient())
     .PlayAlbumOffset(
         "37i9dQZF1DZ06evO3WBS4o",
         "2BndJYJQ17UcEeUFJP5JmY",
         accessToken: await TestsHelper.GetUserAccessToken());
 }
コード例 #12
0
        public async Task CreatePlaylist_PublicNotSpecified_ResultPublicEqualsTrue()
        {
            string accessToken = await TestsHelper.GetUserAccessToken();

            var playlist = await CreatePlaylist(accessToken);

            Assert.IsNotNull(playlist.Public);
            Assert.IsTrue(playlist.Public.Value, "New playlist should default to Public = true");
        }
コード例 #13
0
        public async Task GetCurrentUsersPlaylists_AtLeastOnePlaylistReturnedIsTrue()
        {
            string accessToken = await TestsHelper.GetUserAccessToken();

            await CreatePlaylist(accessToken);

            var playlists = await api.GetCurrentUsersPlaylists <PagedPlaylists>(accessToken : accessToken);

            Assert.IsTrue(playlists.Total > 0, "No playlists found.");
        }
コード例 #14
0
        public async Task GetCurrentlyPlayingTrack_UserAccessToken_NoException()
        {
            // arrange
            var        http        = new HttpClient();
            IPlayerApi player      = new PlayerApi(http);
            string     accessToken = await TestsHelper.GetUserAccessToken();

            // act
            var context = await player.GetCurrentlyPlayingTrack(
                additionalTypes : new[] { "episode" },
                accessToken : accessToken);
        }
コード例 #15
0
        public async Task Play_Paused_NoException()
        {
            // arrange
            var    http        = new HttpClient();
            var    player      = new PlayerApi(http);
            string accessToken = await TestsHelper.GetUserAccessToken();

            await player.Pause(accessToken : accessToken);

            // act
            await player.Play(accessToken : accessToken);
        }
コード例 #16
0
        public async Task SkipNext_UserAccessToken_NoException()
        {
            // arrange
            var    http        = new HttpClient();
            var    player      = new PlayerApi(http);
            string accessToken = await TestsHelper.GetUserAccessToken();

            await player.PlayAlbum("5mAPk4qeNqVLtNydaWbWlf", accessToken);

            // act
            await player.SkipNext(accessToken : accessToken);
        }
コード例 #17
0
        public async Task AddItemsToPlaylist_PlaylistId_SnapshotIdIsNotNull()
        {
            // arrange
            string accessToken = await TestsHelper.GetUserAccessToken();

            var playlist = await CreatePlaylist(accessToken);

            // assert
            Assert.IsNotNull((await api.AddItemsToPlaylist(
                                  playlist.Id,
                                  new string[] { "spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:track:1301WleyT98MSxVHPZCA6M" },
                                  accessToken: accessToken)).SnapshotId);
        }
コード例 #18
0
        public async Task GetRecentlyPlayedTracks_UserAccessToken_NotNull()
        {
            // arrange
            var        http        = new HttpClient();
            IPlayerApi player      = new PlayerApi(http);
            string     accessToken = await TestsHelper.GetUserAccessToken();

            // act
            var history = await player.GetRecentlyPlayedTracks(accessToken : accessToken);

            // assert
            Assert.IsNotNull(history);
        }
コード例 #19
0
        public async Task Repeat_ContextOff_NoException()
        {
            // arrange
            var    http        = new HttpClient();
            var    player      = new PlayerApi(http);
            string accessToken = await TestsHelper.GetUserAccessToken();

            await player.PlayAlbum("5mAPk4qeNqVLtNydaWbWlf", accessToken);

            // act
            await player.Repeat(RepeatStates.Context, accessToken : accessToken);

            await player.Repeat(RepeatStates.Off, accessToken : accessToken);
        }
コード例 #20
0
        public async Task GetRecentlyPlayedTracks_GetNextPage_ItemsAny()
        {
            // arrange
            var        http        = new HttpClient();
            IPlayerApi player      = new PlayerApi(http);
            string     accessToken = await TestsHelper.GetUserAccessToken();

            // act
            var history = await player.GetRecentlyPlayedTracks(accessToken : accessToken);

            var moreHistory = await player.GetRecentlyPlayedTracks(before : history.Cursors.Before, accessToken : accessToken);

            // assert
            Assert.IsTrue(moreHistory.Items.Any());
        }
コード例 #21
0
        public async Task TransferPlayback_GetDevice1IdPlayTrue_NoException()
        {
            // arrange
            var        http        = new HttpClient();
            IPlayerApi player      = new PlayerApi(http);
            string     accessToken = await TestsHelper.GetUserAccessToken();

            var devices = await player.GetDevices(accessToken : accessToken);

            // act
            if (devices.Any())
            {
                await player.TransferPlayback(devices.Last().Id, play : true, accessToken : accessToken);
            }
        }
コード例 #22
0
        public async Task ChangePlaylistDetails_NewNameDescriptionNotChanged_PlaylistDescriptionEqualsOriginalDescription()
        {
            string accessToken = await TestsHelper.GetUserAccessToken();

            string description = $"_Test{Guid.NewGuid():N}";
            string newName     = $"_Test{Guid.NewGuid():N}";
            var    playlist    = await CreatePlaylist(accessToken, description);

            // act
            await api.ChangePlaylistDetails(playlist.Id, new PlaylistDetails { Name = newName },
                                            accessToken : await TestsHelper.GetUserAccessToken());

            // assert
            var changedPlaylist = await api.GetPlaylist(playlist.Id, accessToken);

            Assert.AreEqual(description, changedPlaylist.Description);
        }
コード例 #23
0
 public async Task RemoveItems_PlaylistId_SpotifyUris_SnapshotId_SnapshotIdIsNotNull()
 {
     // act
     Assert.IsNotNull(await api.RemoveItems("46sqDMykUCnssu2F3zWXEF", new string[] { "spotify:track:5ArQzSBevAdXTxRY6Ulhbq" },
                                            "MTQsMWNlNjE5NWJkYWFjOTNmNDM1M2NjZDM4NGNjMWViMTZlNzk0ZWEyYw==", accessToken: await TestsHelper.GetUserAccessToken()));
 }
コード例 #24
0
 public async Task RemoveItems_PlaylistId_SpotifyUris_SnapshotIdIsNotNull()
 {
     // act
     Assert.IsNotNull(await api.RemoveItems("46sqDMykUCnssu2F3zWXEF", new string[] { "spotify:track:5ArQzSBevAdXTxRY6Ulhbq" },
                                            accessToken: await TestsHelper.GetUserAccessToken()));
 }
コード例 #25
0
 public async Task GetCurrentPlaybackInfo_AccessToken_NoException()
 {
     // act
     var result = await new PlayerApi(new HttpClient())
                  .GetCurrentPlaybackInfo(accessToken: await TestsHelper.GetUserAccessToken());
 }