Vcr-sharp lets you record and playback HTTP requests! In this example, WithCassette is an extension method on HttpClientFactory. That extension method sets up a DelgatingHandler to a ReplayingHandler. That ReplayingHandler "loads the cassette" and returns it as a cached response.
using (var httpClient = HttpClientFactory.WithCassette( "my-test-scenario" )) { var request = new HttpRequestMessage(HttpMethod.Get, "http://www.iana.org/domains/reserved" ); var response = await httpClient.SendAsync(request); var body = await response.Content.ReadAsStringAsync(); body.ShouldContain( "Example domains" ); }