Exemplo n.º 1
0
        public async Task EnsureGetTopArtistsReturnsErrorForFailedCall()
        {
            IMusicClient          client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.search_noresults));
            ListResponse <Artist> result = await client.GetTopArtistsAsync();

            Assert.IsNotNull(result, "Expected a result");
            Assert.IsNotNull(result.StatusCode, "Expected a status code");
            Assert.IsTrue(result.StatusCode.HasValue, "Expected a status code");
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a 200 response");
            Assert.IsNotNull(result.Result, "Expected a list of results");
            Assert.IsNull(result.Error, "Expected no error");
            Assert.AreEqual(result.Result.Count, 0, "Expected 0 results");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves top artists (10 most popular) from MixRadio API.
        /// </summary>
        public async void GetTopArtists()
        {
            if (!initialized)
            {
                return;
            }

            ShowProgressIndicator("GetTopArtists()");

            ListResponse <Artist> response = await client.GetTopArtistsAsync();

            if (response != null && response.Result != null && response.Result.Count > 0)
            {
                App.ViewModel.TopArtists.Clear();

                // Insert a place holder for title text
                App.ViewModel.TopArtists.Add(new ArtistModel()
                {
                    Name       = "TitlePlaceholderwho's hot",
                    ItemHeight = "110",
                    ItemWidth  = "450"
                });

                foreach (Artist a in response.Result)
                {
                    App.ViewModel.TopArtists.Add(new ArtistModel()
                    {
                        Name        = a.Name,
                        Country     = CountryCodes.CountryNameFromTwoLetter(a.Country),
                        Genres      = a.Genres[0].Name,
                        Thumb100Uri = a.Thumb100Uri,
                        Thumb200Uri = a.Thumb200Uri,
                        Thumb320Uri = a.Thumb320Uri,
                        Id          = a.Id,
                        ItemWidth   = "205",
                        ItemHeight  = "205"
                    });
                }
            }

            if (response != null && response.Error != null)
            {
                ShowMixRadioApiError();
            }
            HideProgressIndicator("GetTopArtists()");
        }
 public async void EnsureAsyncGetTopArtistsReturnsItems()
 {
     // Only test happy path, as the MusicClient tests cover the unhappy path
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.top_artists));
     ListResponse<Artist> result = await client.GetTopArtistsAsync();
     Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");
 }
Exemplo n.º 4
0
 public async Task EnsureGetTopArtistsReturnsErrorForFailedCall()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.search_noresults));
     ListResponse<Artist> result = await client.GetTopArtistsAsync();
     Assert.IsNotNull(result, "Expected a result");
     Assert.IsNotNull(result.StatusCode, "Expected a status code");
     Assert.IsTrue(result.StatusCode.HasValue, "Expected a status code");
     Assert.AreEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a 200 response");
     Assert.IsNotNull(result.Result, "Expected a list of results");
     Assert.IsNull(result.Error, "Expected no error");
     Assert.AreEqual(result.Result.Count, 0, "Expected 0 results");
 }