Exemplo n.º 1
0
        public void EnsureExclusiveMixesRequestsSendExclusiveTag()
        {
            var exclusiveTag1 = "thisIsTheFirstExclusiveTag";
            var exclusiveTag2 = "thisIsTheSecondExclusiveTag";
            var handler       = new MockApiRequestHandler(Resources.mixes);

            IMusicClient client = new MusicClient("test", "gb", handler);
            var          task   = client.GetMixesAsync("test", exclusiveTag1);

            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair <string, string>(MusicClientCommand.ParamExclusive, exclusiveTag1)));

            task = client.GetMixesAsync("testId", exclusiveTag2);
            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair <string, string>(MusicClientCommand.ParamExclusive, exclusiveTag2)));
        }
Exemplo n.º 2
0
        public void EnsureGetMixesThrowsExceptionForNullGroup()
        {
            MixGroup     nullGroup = null;
            IMusicClient client    = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));

            client.GetMixesAsync(nullGroup).Wait();
        }
Exemplo n.º 3
0
        public void EnsureQueryStringIsBuiltCorrectlyWithOptionalFeaturedArtistsParameter()
        {
            var handler = new MockApiRequestHandler(Resources.mixes);

            IMusicClient client = new MusicClient("test", "gb", handler);
            var          task   = client.GetMixesAsync("test", true);

            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair <string, string>("view", "topftartists")));
        }
Exemplo n.º 4
0
        public async Task EnsureGetMixesReturnsErrorForFailedCall()
        {
            IMusicClient       client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
            ListResponse <Mix> result = await client.GetMixesAsync("test");

            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");
        }
Exemplo n.º 5
0
 public async Task EnsureGetMixesReturnsItems()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));
     ListResponse<Mix> result = await client.GetMixesAsync("test");
     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");
 }
Exemplo n.º 6
0
        public async Task EnsureGetMixesReturnsItems()
        {
            IMusicClient       client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));
            ListResponse <Mix> result = await client.GetMixesAsync("test");

            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");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Retrieves available mixes in a selected mix group from MixRadio API.
        /// </summary>
        /// <param name="id">Id of the mix group.</param>
        public async void GetMixes(string id)
        {
            if (!initialized)
            {
                return;
            }

            ShowProgressIndicator("GetMixes()");

            ListResponse <Mix> response = await client.GetMixesAsync(id);

            // 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)
            {
                ShowMixRadioApiError();
            }
            HideProgressIndicator("GetMixes()");
        }
Exemplo n.º 8
0
 public async Task EnsureGetMixesThrowsExceptionForNullGroupId()
 {
     string       nullId = null;
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));
     await client.GetMixesAsync(nullId);
 }
Exemplo n.º 9
0
 public void EnsureGetMixesAsyncThrowsExceptionForNullGroup()
 {
     MixGroup nullGroup = null;
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));
     client.GetMixesAsync(nullGroup);
 }
Exemplo n.º 10
0
        public void EnsureExclusiveMixesRequestsSendExclusiveTag()
        {
            var exclusiveTag1 = "thisIsTheFirstExclusiveTag";
            var exclusiveTag2 = "thisIsTheSecondExclusiveTag";
            var handler = new MockApiRequestHandler(Resources.mixes);

            IMusicClient client = new MusicClient("test", "gb", handler);
            var task = client.GetMixesAsync("test", exclusiveTag1);
            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair<string, string>(MusicClientCommand.ParamExclusive, exclusiveTag1)));

            task = client.GetMixesAsync(new MixGroup() { Id = "testId" }, exclusiveTag2);
            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair<string, string>(MusicClientCommand.ParamExclusive, exclusiveTag2)));
        }
Exemplo n.º 11
0
        public async void EnsureAsyncGetMixesReturnsItems()
        {
            // Only test happy path, as the MusicClient tests cover the unhappy path
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));

            ListResponse<Mix> result = await client.GetMixesAsync("test");
            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");

            result = await client.GetMixesAsync(new MixGroup() { Id = "test" });
            Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");
        }
Exemplo n.º 12
0
 public async Task EnsureGetMixesReturnsErrorForFailedCall()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
     ListResponse<Mix> result = await client.GetMixesAsync("test");
     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");
 }
Exemplo n.º 13
0
 public async Task EnsureGetMixesThrowsExceptionForNullGroupId()
 {
     string nullId = null;
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));
     await client.GetMixesAsync(nullId);
 }
Exemplo n.º 14
0
        public void EnsureQueryStringIsBuiltCorrectlyWithOptionalFeaturedArtistsParameter()
        {
            var handler = new MockApiRequestHandler(Resources.mixes);

            IMusicClient client = new MusicClient("test", "gb", handler);
            var task = client.GetMixesAsync("test", true);
            Assert.Greater(task.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair<string, string>("view", "topftartists")));
        }