Fixed a bug where request parameters were not added, related to #461

This commit is contained in:
Jonas Dellinger 2020-06-12 15:01:26 +02:00
parent b2d706219f
commit 87127a51a8
3 changed files with 31 additions and 6 deletions

View File

@ -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<IAPIConnector>();
var client = new FollowClient(api.Object);
var request = new FollowOfCurrentUserRequest(FollowOfCurrentUserRequest.Type.Artist);
await client.OfCurrentUser(request);
api.Verify(a => a.Get<FollowedArtistsResponse>(
SpotifyUrls.CurrentUserFollower(),
It.Is<Dictionary<string, string>>(val => val.ContainsKey("type"))
));
}
}
}

View File

@ -60,14 +60,14 @@ namespace SpotifyAPI.Web
{
var request = new FollowOfCurrentUserRequest();
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower(), request.BuildQueryParams());
return OfCurrentUser(request);
}
public Task<FollowedArtistsResponse> OfCurrentUser(FollowOfCurrentUserRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower());
return API.Get<FollowedArtistsResponse>(URLs.CurrentUserFollower(), request.BuildQueryParams());
}
public async Task<bool> Unfollow(UnfollowRequest request)

View File

@ -28,10 +28,9 @@ namespace SpotifyAPI.Web
public Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId)
{
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
var request = new PlaylistGetItemsRequest();
return API.Get<Paging<PlaylistTrack<IPlayableItem>>>(URLs.PlaylistTracks(playlistId), request.BuildQueryParams());
return GetItems(playlistId, request);
}
public Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId, PlaylistGetItemsRequest request)
@ -83,10 +82,9 @@ namespace SpotifyAPI.Web
public Task<FullPlaylist> Get(string playlistId)
{
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
var request = new PlaylistGetRequest(); // We need some defaults
return API.Get<FullPlaylist>(URLs.Playlist(playlistId), request.BuildQueryParams());
return Get(playlistId, request);
}
public Task<FullPlaylist> Get(string playlistId, PlaylistGetRequest request)