Esempio n. 1
0
        public async Task TestSearchAndLookup()
        {
            // Search for "Daft Punk"
            ContentResponse searchResults = await Client.SearchAsync(Namespace.music, "Daft Punk", country : "US").Log();

            Assert.IsNotNull(searchResults, "The search response should not be null");
            AssertPaginatedListIsValid(searchResults.Artists, 1, 1);
            AssertPaginatedListIsValid(searchResults.Albums, 10, 20);
            AssertPaginatedListIsValid(searchResults.Tracks, 25, 100);
            Assert.IsNotNull(searchResults.Tracks.ContinuationToken, "Search results should contain continuation for tracks");

            // Get the 2nd page of track results
            ContentResponse continuedSearchResults =
                await Client.SearchContinuationAsync(Namespace.music, searchResults.Tracks.ContinuationToken).Log();

            Assert.IsNotNull(continuedSearchResults, "The continued search response should not be null");
            Assert.IsNull(continuedSearchResults.Artists, "The continued search response should not contain artists");
            Assert.IsNull(continuedSearchResults.Albums, "The continued search response should not contain albums");
            AssertPaginatedListIsValid(continuedSearchResults.Tracks, 25, 100);

            // List tracks in the first album
            Album           firstAlbum        = searchResults.Albums.Items.First();
            ContentResponse albumTrackResults = await Client.LookupAsync(firstAlbum.Id, extras : ExtraDetails.Tracks, country : "US").Log();

            AssertPaginatedListIsValid(albumTrackResults.Albums, 1);
            Album firstAlbumLookup = albumTrackResults.Albums.Items.First();

            Assert.AreEqual(firstAlbum.Id, firstAlbumLookup.Id, "Album ids should be the same");
            Assert.IsNotNull(firstAlbumLookup.Tracks, "Album should have tracks");
            Assert.IsNotNull(firstAlbumLookup.Tracks.Items, "Album should have tracks");
        }