Last active
May 22, 2020 00:23
-
-
Save josephwoodward/f309039e18912f1b041d086b36257d20 to your computer and use it in GitHub Desktop.
hc3.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arrange | |
var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true}; | |
new HttpRequestInterceptionBuilder() | |
.Requests() | |
.ForHttps() | |
.ForHost("bbc.co.uk") | |
.ForPath("/news") | |
.Responds() | |
.WithStatus(500) | |
.RegisterWith(options); | |
var handler = options.CreateHttpMessageHandler(); | |
// Act | |
var client = new HttpClient(handler); | |
var response = await client.GetAsync("https://bbc.co.uk/news"); | |
// Assert | |
response.StatusCode.ShouldBe(HttpStatusCode.InternalServerError); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment