Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves available mixes in a selected mix group from Nokia Music API.
        /// </summary>
        /// <param name="id">Id of the mix group.</param>
        public void GetMixes(string id)
        {
            if (!initialized)
            {
                return;
            }

            client.GetMixes((ListResponse <Mix> response) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    // Use results
                    if (response != null && response.Result != null && response.Result.Count > 0)
                    {
                        App.ViewModel.Mixes.Clear();

                        foreach (Mix m in response.Result)
                        {
                            string parentalAdvisoryString = "";

                            if (m.ParentalAdvisory)
                            {
                                parentalAdvisoryString = "Parental advisory";
                            }

                            App.ViewModel.Mixes.Add(new MixModel()
                            {
                                Name             = m.Name,
                                ParentalAdvisory = parentalAdvisoryString,
                                Id          = m.Id,
                                Thumb100Uri = m.Thumb100Uri,
                                Thumb200Uri = m.Thumb200Uri,
                                Thumb320Uri = m.Thumb320Uri,
                                ItemWidth   = "205",
                                ItemHeight  = "205"
                            });
                        }
                    }

                    if (response != null && response.Error != null)
                    {
                        ShowNokiaMusicApiError();
                    }
                    HideProgressIndicator("GetMixes()");
                });
            }, id);
            ShowProgressIndicator("GetMixes()");
        }
Ejemplo n.º 2
0
 public void EnsureGetMixesReturnsItems()
 {
     IMusicClient client = new MusicClient("test", "test", "gb", new MockApiRequestHandler(Resources.mixes));
     client.GetMixes(
         (ListResponse<Mix> 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");
         },
         new MixGroup() { Id = "test" });
 }
Ejemplo n.º 3
0
 public void EnsureGetMixesThrowsExceptionForNullCallback()
 {
     IMusicClient client = new MusicClient("test", "test", "gb", new MockApiRequestHandler(Resources.mixes));
     client.GetMixes(null, "test");
 }
Ejemplo n.º 4
0
 public void EnsureGetMixesThrowsExceptionForNullGroup()
 {
     MixGroup nullGroup = null;
     IMusicClient client = new MusicClient("test", "test", "gb", new MockApiRequestHandler(Resources.mixes));
     client.GetMixes((ListResponse<Mix> result) => { }, nullGroup);
 }
Ejemplo n.º 5
0
 public void EnsureGetMixesReturnsErrorForFailedCall()
 {
     IMusicClient client = new MusicClient("test", "test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
     client.GetMixes(
         (ListResponse<Mix> 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.AreNotEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a non-OK response");
             Assert.IsNotNull(result.Error, "Expected an error");
             Assert.AreEqual(typeof(ApiCallFailedException), result.Error.GetType(), "Expected an ApiCallFailedException");
         },
         "test");
 }
Ejemplo n.º 6
0
 public void EnsureGetMixesThrowsExceptionForNullGroupId()
 {
     string nullId = null;
     IMusicClient client = new MusicClient("test", "test", "gb", new SuccessfulMockApiRequestHandler());
     client.GetMixes((ListResponse<Mix> result) => { }, nullId);
 }