public void ShouldUseFrontEndWebSiteRootForHttpClient() { const string expectedWebSiteRoot = "web site root"; MockedConfigSettings.SetupGet(cs => cs.FrontEndWebSiteRoot).Returns(expectedWebSiteRoot); MockedHttpClientAdapter.Setup(hca => hca.GetHttpClient(It.IsAny <string>())).Returns(MockedHttpClient.Object); MockedHttpClient.Setup(hc => hc.Get(It.IsAny <string>())).Returns(OkHttpResponse); PackageAuthenticator.EnsureKeyCanAccessPackage("key", "packageId", "packageVersion"); MockedHttpClientAdapter.Verify(hca => hca.GetHttpClient(expectedWebSiteRoot), Times.Once(), "Should have called HttpClientAdpater's GetHttpClient() with expected web site root."); }
public void ShouldPutValidatePackageKeyUriAndParametersInRequestUri() { const string expectedValidatePackageKeyUri = "foo"; const string key = "asdf"; const string packageId = "packageId"; const string packageVersion = "packageVersion"; string expectedUri = string.Format("{0}/{1}/{2}/{3}", expectedValidatePackageKeyUri, key, packageId, packageVersion); MockedConfigSettings.SetupGet(cs => cs.ValidatePackageKeyUri).Returns(expectedValidatePackageKeyUri); MockedHttpClientAdapter.Setup(hca => hca.GetHttpClient(It.IsAny <string>())).Returns(MockedHttpClient.Object); MockedHttpClient.Setup(hc => hc.Get(It.IsAny <string>())).Returns(OkHttpResponse); PackageAuthenticator.EnsureKeyCanAccessPackage(key, packageId, packageVersion); MockedHttpClient.Verify(hc => hc.Get(expectedUri), Times.Once(), string.Format("Should have called HttpClient's Get() with expected URI '{0}'.", expectedUri)); }