Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves top artists (10 most popular) from Nokia Music API.
        /// </summary>
        public void GetTopArtists()
        {
            if (!initialized)
            {
                return;
            }

            client.GetTopArtists((ListResponse <Artist> response) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    // Use results
                    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)
                    {
                        ShowNokiaMusicApiError();
                    }
                    HideProgressIndicator("GetTopArtists()");
                });
            });
            ShowProgressIndicator("GetTopArtists()");
        }
 public void EnsureGetTopArtistsReturnsArtists()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.top_artists));
     client.GetTopArtists(
         (ListResponse<Artist> result) =>
         {
             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.Greater(result.Result.Count, 0, "Expected more than 0 results");
         });
 }
 public void EnsureGetTopArtistsThrowsExceptionForNullCallback()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.top_artists));
     client.GetTopArtists(null);
 }
Ejemplo n.º 4
0
 public void EnsureGetTopArtistsThrowsExceptionForNullCallback()
 {
     IMusicClient client = new MusicClient("test", "test", "gb", new SuccessfulMockApiRequestHandler());
     client.GetTopArtists(null);
 }