using System.Reflection; using System.Collections.Generic; using System.Threading.Tasks; using Moq; using NUnit.Framework; using SpotifyAPI.Web.Http; using System.Threading; namespace SpotifyAPI.Web.Tests { [TestFixture] public class SpotifyClientTest { [Test] public async Task NextPageForIPaginatable() { var api = new Mock(); var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object); var spotify = new SpotifyClient(config); var response = new SearchResponse { Albums = new Paging { Next = "https://next-url", } }; await spotify.NextPage(response.Albums); api.Verify(a => a.Get(new System.Uri("https://next-url"), It.IsAny()), Times.Once); } [Test] public async Task NextPageForCursorPaging() { var api = new Mock(); var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object); var spotify = new SpotifyClient(config); var response = new CursorPaging { Next = "https://next-url" }; await spotify.NextPage(response); api.Verify(a => a.Get>(new System.Uri("https://next-url"), It.IsAny()), Times.Once); } [Test] public async Task NextPageForPaging() { var api = new Mock(); var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object); var spotify = new SpotifyClient(config); var response = new Paging { Next = "https://next-url" }; await spotify.NextPage(response); api.Verify(a => a.Get>(new System.Uri("https://next-url"), It.IsAny()), Times.Once); } [Test] public async Task PreviousPageForPaging() { var api = new Mock(); var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object); var spotify = new SpotifyClient(config); var response = new Paging { Previous = "https://previous-url" }; await spotify.PreviousPage(response); api.Verify(a => a.Get>(new System.Uri("https://previous-url"), It.IsAny()), Times.Once); } [Test] public async Task PreviousPageForCustomPaging() { var api = new Mock(); var config = SpotifyClientConfig.CreateDefault("FakeToken").WithAPIConnector(api.Object); var spotify = new SpotifyClient(config); var response = new Paging { Previous = "https://previous-url" }; await spotify.PreviousPage(response); api.Verify(a => a.Get(new System.Uri("https://previous-url"), It.IsAny()), Times.Once); } } }