private static async Task TestGetIsSupportedAsync(string[] wwwAuthHeaders, bool expected) { var context = new TestCommandContext(); var uri = new Uri("https://example.com"); var wiaResponse = new HttpResponseMessage(HttpStatusCode.Unauthorized); foreach (string headerValue in wwwAuthHeaders) { wiaResponse.Headers.WwwAuthenticate.ParseAdd(headerValue); } var httpHandler = new TestHttpMessageHandler { ThrowOnUnexpectedRequest = true }; httpHandler.Setup(HttpMethod.Head, uri, wiaResponse); context.HttpClientFactory.MessageHandler = httpHandler; var wiaAuth = new WindowsIntegratedAuthentication(context); bool actual = await wiaAuth.GetIsSupportedAsync(uri); Assert.Equal(expected, actual); httpHandler.AssertRequest(HttpMethod.Head, uri, expectedNumberOfCalls: 1); }
public async Task WindowsIntegratedAuthentication_GetIsSupportedAsync_NullUri_ThrowsException() { var context = new TestCommandContext(); var wiaAuth = new WindowsIntegratedAuthentication(context); await Assert.ThrowsAsync <ArgumentNullException>(() => wiaAuth.GetIsSupportedAsync(null)); }