using System; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Nancy; using Nancy.Testing; using Sony.Filtr.AdminAPI.Modules.SpotifySpecific; using Sony.Filtr.Contracts.Entities; namespace Sony.Filtr.AdminAPI.Testing { [TestClass] public class SpotifyPlaylistTracklistModuleTest : FiltrUnitTestBase { private static Browser _DefaultLoggedInBrowser; [ClassInitialize] public static void InitTestSuite(TestContext testContext) { _DefaultLoggedInBrowser = BuildDefaultBrowser(); } [TestMethod] public void Can_Get_Dates_For_Historic_Tracklist_For_Playlist() { var url = "/spotifyPlaylist/tracklisthistory/dates"; var result = _DefaultLoggedInBrowser.Get(url, with => { with.Query("playlistUri", "spotify:user:sonymusicentertainment:playlist:7AnvOrPIQLV8VIASFhN07Z"); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var responseModel = result.Body.DeserializeJson>(); Assert.IsNotNull(responseModel); Assert.IsTrue(responseModel.Any()); } [TestMethod] public void Can_Get_Historic_Tracklist_For_Playlist() { var playlistUri = "spotify:user:sonymusicentertainment:playlist:7AnvOrPIQLV8VIASFhN07Z"; var date = "2017-03-15"; var url = $"/spotifyPlaylist/tracklisthistory/{date}/"; var result = _DefaultLoggedInBrowser.Get(url, with => { with.Query("playlistUri", playlistUri); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var responseModel = result.Body.DeserializeJson>(); Assert.IsNotNull(responseModel); Assert.IsNotNull(responseModel.Items); Assert.IsTrue(responseModel.Items.Any()); } [TestMethod] public void Can_Get_Current_Tracklist_For_Playlist() { var url = "/spotifyPlaylist/tracklist/"; var result = _DefaultLoggedInBrowser.Get(url, with => { with.Query("playlistUri", "spotify:user:sonymusicentertainment:playlist:7AnvOrPIQLV8VIASFhN07Z"); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var responseModel = result.Body.DeserializeJson>(); Assert.IsNotNull(responseModel); Assert.IsNotNull(responseModel.Items); Assert.IsTrue(responseModel.Items.Any()); } [TestMethod] public void Can_Get_Current_Tracklist_For_Playlist_With_region() { var url = "/spotifyPlaylist/tracklist/"; var result = _DefaultLoggedInBrowser.Get(url, with => { with.Query("playlistUri", "spotify:user:sonymusicentertainment:playlist:7AnvOrPIQLV8VIASFhN07Z"); with.Query("region", "se"); }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); var responseModel = result.Body.DeserializeJson>(); Assert.IsNotNull(responseModel); Assert.IsNotNull(responseModel.Items); Assert.IsTrue(responseModel.Items.Any()); } } }