public void HttpClientProvider_ConstructedWithNullWebCfgReader_ShouldThrow() { // Arrange HttpClientProvider client = new HttpClientProvider(null); // Act var returnedValue = client.GetHttpClientInstance(); }
public void NewHttpClientProviderInstance_GivenWorkingWebCfgReader_ShouldReturnBaseAddrCfgdHttpClient() { // Arrange HttpClientProvider client = new HttpClientProvider(mockWebConfigReader.Object); // Act var returnedValue = client.GetHttpClientInstance(); // Assert Assert.IsNotNull(returnedValue); Assert.IsInstanceOfType(returnedValue, typeof(HttpClient)); Assert.AreEqual(expectedWebCfgUri, returnedValue.BaseAddress); }
public void NewHttpClientFromProvider_ShouldInclAcceptHeaderItem_ShouldPass() { // Arrange HttpClientProvider client = new HttpClientProvider(mockWebConfigReader.Object); MediaTypeWithQualityHeaderValue expectedMediaType = new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"); // Act var returnedHttpClient = client.GetHttpClientInstance(); var returnedAcceptHdr = returnedHttpClient.DefaultRequestHeaders.Accept.FirstOrDefault(); // Assert Assert.AreEqual(expectedMediaType, returnedAcceptHdr); }
public void NewHttpClientFromProvider_ShouldInclUserAgentHeaderItem_ShouldPass() { // Arrange HttpClientProvider client = new HttpClientProvider(mockWebConfigReader.Object); var productInfo = new ProductHeaderValue("PRHawkSkf"); var expectedProductInfoHdrVal = new ProductInfoHeaderValue(productInfo); // Act var returnedHttpClient = client.GetHttpClientInstance(); var returnedAcceptHdr = returnedHttpClient.DefaultRequestHeaders.UserAgent.FirstOrDefault(); // Assert Assert.AreEqual(expectedProductInfoHdrVal, returnedAcceptHdr); }