Example #1
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")));
        }
Example #2
0
        public void EnsureExclusiveMixGroupRequestsSendExclusiveTag()
        {
            var exclusiveTag = "thisIsTheExclusiveTag";
            var handler      = new MockApiRequestHandler(Resources.mixgroups);

            IMusicClient client     = new MusicClient("test", "gb", handler);
            var          groupsTask = client.GetMixGroupsAsync(exclusiveTag);

            Assert.Greater(groupsTask.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair <string, string>(MusicClientCommand.ParamExclusive, exclusiveTag)));
        }
Example #3
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)));
        }
 public async Task EnsureCountryResolverPassesDefaultSettings()
 {
     MockApiRequestHandler mockHandler = new MockApiRequestHandler(Resources.country);
     ICountryResolver client = new CountryResolver("test1", mockHandler);
     bool result = await client.CheckAvailabilityAsync("xx");
     Assert.AreEqual("test1", mockHandler.LastUsedSettings.ClientId);
     Assert.AreEqual(null, mockHandler.LastUsedSettings.CountryCode);
     Assert.AreEqual(false, mockHandler.LastUsedSettings.CountryCodeBasedOnRegionInfo);
     Assert.AreEqual(MusicClientCommand.DefaultBaseApiUri, mockHandler.LastUsedSettings.ApiBaseUrl);
     Assert.AreEqual(MusicClientCommand.DefaultSecureBaseApiUri, mockHandler.LastUsedSettings.SecureApiBaseUrl);
 }
 public async Task EnsureCountryWithoutItemsRaisesApiCallFailedException()
 {
     MockApiRequestHandler mockHandler = new MockApiRequestHandler(System.Text.Encoding.UTF8.GetBytes("{ \"items\": [] }"));
     ICountryResolver client = new CountryResolver("test1", mockHandler);
     bool result = await client.CheckAvailabilityAsync("xx");
 }
Example #6
0
        public void EnsureExclusiveMixGroupRequestsSendExclusiveTag()
        {
            var exclusiveTag = "thisIsTheExclusiveTag";
            var handler = new MockApiRequestHandler(Resources.mixgroups);

            IMusicClient client = new MusicClient("test", "gb", handler);
            var groupsTask = client.GetMixGroupsAsync(exclusiveTag);
            Assert.Greater(groupsTask.Result.Result.Count, 0, "Expected more than 0 results");
            Assert.IsTrue(handler.LastQueryString.Contains(new KeyValuePair<string, string>(MusicClientCommand.ParamExclusive, exclusiveTag)));
        }
Example #7
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)));
        }
Example #8
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")));
        }
        public void EnsureCountryResolverPassesDefaultSettings()
        {
            MockApiRequestHandler mockHandler = new MockApiRequestHandler(FakeResponse.NotFound());
            ICountryResolver client = new CountryResolver("test1", mockHandler);
            client.CheckAvailability(result => Assert.IsNotNull(result, "Expected a result"), "xx");

            Assert.AreEqual("test1", mockHandler.LastUsedSettings.AppId);
            Assert.AreEqual(null, mockHandler.LastUsedSettings.CountryCode);
            Assert.AreEqual(false, mockHandler.LastUsedSettings.CountryCodeBasedOnRegionInfo);
        }