public void CheckParametersAreValidated() { IApiUriBuilder builder = new ApiUriBuilder(); // Check ApiMethod param... Assert.Throws(typeof(ArgumentNullException), new TestDelegate(() => { builder.BuildUri(null, null, null); })); // Check settings param... Assert.Throws(typeof(ArgumentNullException), new TestDelegate(() => { builder.BuildUri(new SearchCommand(), null, null); })); // Check API Key is required... Assert.Throws(typeof(ApiCredentialsRequiredException), new TestDelegate(() => { builder.BuildUri(new CountryResolverCommand(ClientId, null), new MockMusicClientSettings(null, null, null), null); })); // Check Country Code is required... Assert.Throws(typeof(CountryCodeRequiredException), new TestDelegate(() => { builder.BuildUri(new SearchCommand(), new MockMusicClientSettings(ClientId, null, null), null); })); }
public void EnsureSpecificApiVersionCommandsUsesCorrectVersion() { MockApiCommand cmd = new MockApiCommand() { BaseApiVersion = "2.x/" }; IMusicClientSettings settings = new MockMusicClientSettings(ClientId, Country, null); IApiUriBuilder builder = new ApiUriBuilder(); Uri uri = builder.BuildUri(cmd, settings, null); Assert.IsTrue(uri.ToString().Contains("2.x/"), "Expected the correct version to be included in the URI"); }
public void EnsureBlankLanguageCommandsDoNotIncludeLanguage() { MockApiCommand cmd = new MockApiCommand(); IMusicClientSettings settings = new MockMusicClientSettings(ClientId, Country, null); IApiUriBuilder builder = new ApiUriBuilder(); Uri uri = builder.BuildUri(cmd, settings, null); Assert.IsFalse(uri.ToString().Contains("lang="), "Expected the language code not to be included in the URI"); }
public void EnsureBlankTerritoryCommandsDoNotIncludeTerritory() { MockBlankTerritoryCommand cmd = new MockBlankTerritoryCommand(); IMusicClientSettings settings = new MockMusicClientSettings("test", "country", null); IApiUriBuilder builder = new ApiUriBuilder(); Uri uri = builder.BuildUri(cmd, settings, null); Assert.IsTrue(uri.ToString().Contains("/-/"), "Expected the country code to be '-'"); Assert.IsFalse(uri.ToString().Contains("country"), "Expected the country code not to be included in the URI"); }