From 87127a51a8306cc5290a43030387bbd932ca0ff1 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Fri, 12 Jun 2020 15:01:26 +0200 Subject: [PATCH] Fixed a bug where request parameters were not added, related to #461 --- .../Clients/FollowClientTest.cs | 27 +++++++++++++++++++ SpotifyAPI.Web/Clients/FollowClient.cs | 4 +-- SpotifyAPI.Web/Clients/PlaylistsClient.cs | 6 ++--- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 SpotifyAPI.Web.Tests/Clients/FollowClientTest.cs diff --git a/SpotifyAPI.Web.Tests/Clients/FollowClientTest.cs b/SpotifyAPI.Web.Tests/Clients/FollowClientTest.cs new file mode 100644 index 00000000..3826f68f --- /dev/null +++ b/SpotifyAPI.Web.Tests/Clients/FollowClientTest.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using SpotifyAPI.Web.Http; + +namespace SpotifyAPI.Web.Tests +{ + [TestFixture] + public class FollowClientTest + { + [Test] + public async Task OfCurrentUser_PassesQueryParams() + { + var api = new Mock(); + var client = new FollowClient(api.Object); + + var request = new FollowOfCurrentUserRequest(FollowOfCurrentUserRequest.Type.Artist); + await client.OfCurrentUser(request); + + api.Verify(a => a.Get( + SpotifyUrls.CurrentUserFollower(), + It.Is>(val => val.ContainsKey("type")) + )); + } + } +} diff --git a/SpotifyAPI.Web/Clients/FollowClient.cs b/SpotifyAPI.Web/Clients/FollowClient.cs index 96fe3988..e3705dc6 100644 --- a/SpotifyAPI.Web/Clients/FollowClient.cs +++ b/SpotifyAPI.Web/Clients/FollowClient.cs @@ -60,14 +60,14 @@ namespace SpotifyAPI.Web { var request = new FollowOfCurrentUserRequest(); - return API.Get(URLs.CurrentUserFollower(), request.BuildQueryParams()); + return OfCurrentUser(request); } public Task OfCurrentUser(FollowOfCurrentUserRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); - return API.Get(URLs.CurrentUserFollower()); + return API.Get(URLs.CurrentUserFollower(), request.BuildQueryParams()); } public async Task Unfollow(UnfollowRequest request) diff --git a/SpotifyAPI.Web/Clients/PlaylistsClient.cs b/SpotifyAPI.Web/Clients/PlaylistsClient.cs index c134d7d1..3b3ab3e5 100644 --- a/SpotifyAPI.Web/Clients/PlaylistsClient.cs +++ b/SpotifyAPI.Web/Clients/PlaylistsClient.cs @@ -28,10 +28,9 @@ namespace SpotifyAPI.Web public Task>> GetItems(string playlistId) { - Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId)); var request = new PlaylistGetItemsRequest(); - return API.Get>>(URLs.PlaylistTracks(playlistId), request.BuildQueryParams()); + return GetItems(playlistId, request); } public Task>> GetItems(string playlistId, PlaylistGetItemsRequest request) @@ -83,10 +82,9 @@ namespace SpotifyAPI.Web public Task Get(string playlistId) { - Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId)); var request = new PlaylistGetRequest(); // We need some defaults - return API.Get(URLs.Playlist(playlistId), request.BuildQueryParams()); + return Get(playlistId, request); } public Task Get(string playlistId, PlaylistGetRequest request)