Repository navigation
Expand file tree
/
Copy pathSpotifyClientTest.cs
More file actions
97 lines (82 loc) · 2.98 KB
/
Copy pathSpotifyClientTest.cs
File metadata and controls
97 lines (82 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using SpotifyAPI.Web.Http;
namespace SpotifyAPI.Web.Tests
{
[TestFixture]
public class SpotifyClientTest
{
[Test]
public async Task NextPageForIPaginatable()
{
var api = new Mock<IAPIConnector>();
var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object);
var spotify = new SpotifyClient(config);
var response = new SearchResponse
{
Albums = new Paging<SimpleAlbum, SearchResponse>
{
Next = "https://next-url",
}
};
await spotify.NextPage(response.Albums);
api.Verify(a => a.Get<SearchResponse>(new System.Uri("https://next-url"), It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task NextPageForCursorPaging()
{
var api = new Mock<IAPIConnector>();
var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object);
var spotify = new SpotifyClient(config);
var response = new CursorPaging<PlayHistoryItem>
{
Next = "https://next-url"
};
await spotify.NextPage(response);
api.Verify(a => a.Get<CursorPaging<PlayHistoryItem>>(new System.Uri("https://next-url"), It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task NextPageForPaging()
{
var api = new Mock<IAPIConnector>();
var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object);
var spotify = new SpotifyClient(config);
var response = new Paging<PlayHistoryItem>
{
Next = "https://next-url"
};
await spotify.NextPage(response);
api.Verify(a => a.Get<Paging<PlayHistoryItem>>(new System.Uri("https://next-url"), It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task PreviousPageForPaging()
{
var api = new Mock<IAPIConnector>();
var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object);
var spotify = new SpotifyClient(config);
var response = new Paging<PlayHistoryItem>
{
Previous = "https://previous-url"
};
await spotify.PreviousPage(response);
api.Verify(a => a.Get<Paging<PlayHistoryItem>>(new System.Uri("https://previous-url"), It.IsAny<CancellationToken>()), Times.Once);
}
[Test]
public async Task PreviousPageForCustomPaging()
{
var api = new Mock<IAPIConnector>();
var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object);
var spotify = new SpotifyClient(config);
var response = new Paging<PlayHistoryItem, SearchResponse>
{
Previous = "https://previous-url"
};
await spotify.PreviousPage(response);
api.Verify(a => a.Get<SearchResponse>(new System.Uri("https://previous-url"), It.IsAny<CancellationToken>()), Times.Once);
}
}
}