mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
a27c3729c8
* add top tracks & artists endpoints * fix file extenstion * added TODO * Add Methods to interface * Add Top items query class * implement query into UserProfileClient.cs - Top Requests * Tidy Up Naming * Removed random json file change * Added Tests. * run formatter * remove additional namespace --------- Co-authored-by: Jonas Dellinger <jonas@dellinger.dev>
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using SpotifyAPI.Web.Http;
|
|
|
|
namespace SpotifyAPI.Web
|
|
{
|
|
[TestFixture]
|
|
public class UserProfileClientTest
|
|
{
|
|
[Test]
|
|
public async Task Current()
|
|
{
|
|
var api = new Mock<IAPIConnector>();
|
|
var client = new UserProfileClient(api.Object);
|
|
|
|
await client.Current();
|
|
|
|
api.Verify(a => a.Get<PrivateUser>(SpotifyUrls.Me(), It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Get()
|
|
{
|
|
var userId = "johnnycrazy";
|
|
var api = new Mock<IAPIConnector>();
|
|
var client = new UserProfileClient(api.Object);
|
|
|
|
await client.Get(userId);
|
|
|
|
api.Verify(a => a.Get<PublicUser>(SpotifyUrls.User(userId), It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetTopTracks()
|
|
{
|
|
|
|
var request = new UsersTopItemsRequest(TimeRange.LongTerm);
|
|
var api = new Mock<IAPIConnector>();
|
|
var client = new UserProfileClient(api.Object);
|
|
|
|
var res = await client.GetTopTracks(request);
|
|
|
|
api.Verify(a => a.Get<UsersTopTracksResponse>(SpotifyUrls.TopTracks(), request.BuildQueryParams(), It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetTopArtists()
|
|
{
|
|
|
|
var request = new UsersTopItemsRequest(TimeRange.LongTerm);
|
|
var api = new Mock<IAPIConnector>();
|
|
var client = new UserProfileClient(api.Object);
|
|
|
|
await client.GetTopArtists(request);
|
|
|
|
api.Verify(a => a.Get<UsersTopArtistsResponse>(SpotifyUrls.TopArtists(), request.BuildQueryParams(), It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
}
|
|
}
|