Skip to content

Instantly share code, notes, and snippets.

@josephwoodward
Last active May 21, 2020 23:56
Show Gist options
  • Save josephwoodward/f865a11e995ae261c783a95787b6d2f2 to your computer and use it in GitHub Desktop.
Save josephwoodward/f865a11e995ae261c783a95787b6d2f2 to your computer and use it in GitHub Desktop.
hc1
// Arrange
var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true};
new HttpRequestInterceptionBuilder()
.Requests()
.ForHttps()
.ForHost("bbc.co.uk")
.ForPath("/news")
.Responds()
.WithStatus(500)
.RegisterWith(options);
// Act
HttpClient client = options.CreateHttpClient();
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