public async Task EnsureAsyncGetNewReleasesReturnsItems()
        {
            // Only test happy path, as the MusicClient tests cover the unhappy path
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));

            ListResponse<Product> result = await client.GetNewReleasesAsync(Category.Album);
            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");

            result = await client.GetNewReleasesAsync(Category.Album, 0, 10);
            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");
        }
Esempio n. 2
0
        public async Task EnsureAsyncGetNewReleasesReturnsItems()
        {
            // Only test happy path, as the MusicClient tests cover the unhappy path
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));

            ListResponse <Product> result = await client.GetNewReleasesAsync(Category.Album);

            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");

            result = await client.GetNewReleasesAsync(Category.Album, 0, 10);

            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");
        }
 public async Task EnsureGetNewReleasesReturnsErrorForFailedCall()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
     ListResponse<Product> result = await client.GetNewReleasesAsync(Category.Album);
     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");
 }
Esempio n. 4
0
        public async Task EnsureGetNewReleasesReturnsErrorForFailedCall()
        {
            IMusicClient           client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
            ListResponse <Product> result = await client.GetNewReleasesAsync(Category.Album);

            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");
        }
Esempio n. 5
0
        public async Task NearestArtists()
        {
            client = new MusicClient(ClientIds.MUSIC_EXPLORER_APP_ID);
            var result = await client.GetNewReleasesAsync(Category.Album, 0, 10);
            NewRelease = new ObservableCollection<Group>();

            foreach (var item in result.Result)
            {
                Image image = new Image();
                image.Source = new BitmapImage(item.Thumb200Uri);

                NewRelease.Add(new Newreales { image = image.Source, Name = item.Name, Weburi = item.WebUri });
            }
            Image images = new Image();
            images.Source = new BitmapImage(new Uri(result.Result.FirstOrDefault().Thumb320Uri.AbsoluteUri));
            FeatuteName = result.Result.FirstOrDefault().Name;
            FeatuteImage = new BitmapImage(new Uri(result.Result.FirstOrDefault().Thumb320Uri.AbsoluteUri));

            NewRelease.Insert(2, new AdvertModel { });
            NewRelease.Insert(8, new AdvertModel { });
        }
 public async Task EnsureGetNewReleasesReturnsItems()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     this.ValidateNewReleasesResponse(await client.GetNewReleasesAsync(Category.Album));
 }
 public async Task EnsureGetNewReleasesThrowsExceptionForUnsupportedCategory()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     await client.GetNewReleasesAsync(Category.Unknown);
 }
Esempio n. 8
0
        public async Task EnsureGetNewReleasesReturnsItems()
        {
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));

            this.ValidateNewReleasesResponse(await client.GetNewReleasesAsync(Category.Album));
        }
Esempio n. 9
0
        public void EnsureGetNewReleasesThrowsExceptionForUnsupportedCategory()
        {
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));

            client.GetNewReleasesAsync(Category.Unknown).Wait();
        }
Esempio n. 10
0
        /// <summary>
        /// Retrieves new releases (10 latest albums) from MixRadio API.
        /// </summary>
        public async void GetNewReleases()
        {
            if (!initialized)
            {
                return;
            }

            ShowProgressIndicator("GetNewReleases()");
            ListResponse <Product> response = await client.GetNewReleasesAsync(Category.Album);

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

                // Insert a place holder for title text
                App.ViewModel.NewReleases.Add(new ProductModel()
                {
                    Performers = "TitlePlaceholderwhat's new",
                    ItemHeight = "110",
                    ItemWidth  = "450"
                });

                foreach (Product p in response.Result)
                {
                    string categoryString = "Album";

                    if (p.Category == Category.Single)
                    {
                        categoryString = "Single";
                    }
                    else if (p.Category == Category.Track)
                    {
                        categoryString = "Track";
                    }

                    string performersString = "";

                    if (p.Performers != null && p.Performers.Length > 0)
                    {
                        performersString = p.Performers[0].Name;
                    }

                    App.ViewModel.NewReleases.Add(new ProductModel()
                    {
                        Performers  = performersString,
                        Name        = p.Name,
                        Category    = categoryString,
                        Thumb100Uri = p.Thumb100Uri,
                        Thumb200Uri = p.Thumb200Uri,
                        Thumb320Uri = p.Thumb320Uri,
                        Id          = p.Id,
                        ItemWidth   = "205",
                        ItemHeight  = "205"
                    });
                }
            }

            if (response != null && response.Error != null)
            {
                ShowMixRadioApiError();
            }

            HideProgressIndicator("GetNewReleases()");
        }