Skip to content

Commit 87127a5

Browse files
committed
Fixed a bug where request parameters were not added, related to #461
1 parent b2d7062 commit 87127a5

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Moq;
4+
using NUnit.Framework;
5+
using SpotifyAPI.Web.Http;
6+
7+
namespace SpotifyAPI.Web.Tests
8+
{
9+
[TestFixture]
10+
public class FollowClientTest
11+
{
12+
[Test]
13+
public async Task OfCurrentUser_PassesQueryParams()
14+
{
15+
var api = new Mock<IAPIConnector>();
16+
var client = new FollowClient(api.Object);
17+
18+
var request = new FollowOfCurrentUserRequest(FollowOfCurrentUserRequest.Type.Artist);
19+
await client.OfCurrentUser(request);
20+
21+
api.Verify(a => a.Get<FollowedArtistsResponse>(
22+
SpotifyUrls.CurrentUserFollower(),
23+
It.Is<Dictionary<string, string>>(val => val.ContainsKey("type"))
24+
));
25+
}
26+
}
27+
}

SpotifyAPI.Web/Clients/FollowClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public Task<FollowedArtistsResponse> OfCurrentUser()
6060
{
6161
var request = new FollowOfCurrentUserRequest();
6262

63-
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower(), request.BuildQueryParams());
63+
return OfCurrentUser(request);
6464
}
6565

6666
public Task<FollowedArtistsResponse> OfCurrentUser(FollowOfCurrentUserRequest request)
6767
{
6868
Ensure.ArgumentNotNull(request, nameof(request));
6969

70-
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower());
70+
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower(), request.BuildQueryParams());
7171
}
7272

7373
public async Task<bool> Unfollow(UnfollowRequest request)

SpotifyAPI.Web/Clients/PlaylistsClient.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public Task<SnapshotResponse> AddItems(string playlistId, PlaylistAddItemsReques
2828

2929
public Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId)
3030
{
31-
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
3231
var request = new PlaylistGetItemsRequest();
3332

34-
return API.Get<Paging<PlaylistTrack<IPlayableItem>>>(URLs.PlaylistTracks(playlistId), request.BuildQueryParams());
33+
return GetItems(playlistId, request);
3534
}
3635

3736
public Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId, PlaylistGetItemsRequest request)
@@ -83,10 +82,9 @@ public Task<Paging<SimplePlaylist>> GetUsers(string userId, PlaylistGetUsersRequ
8382

8483
public Task<FullPlaylist> Get(string playlistId)
8584
{
86-
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
8785
var request = new PlaylistGetRequest(); // We need some defaults
8886

89-
return API.Get<FullPlaylist>(URLs.Playlist(playlistId), request.BuildQueryParams());
87+
return Get(playlistId, request);
9088
}
9189

9290
public Task<FullPlaylist> Get(string playlistId, PlaylistGetRequest request)

0 commit comments

Comments
 (0)