Skip to content

Releases: Adolfok3/Fresp

3.1.1

Choose a tag to compare

@Adolfok3 Adolfok3 released this 13 Aug 23:32
bce4d68

[3.1.1]

Fixed

  • Disposal of the original response when replaced by a FromResponse fake. When a FromResponse handler returned a new HttpResponseMessage, the original response (and its HttpContent) was abandoned without being disposed, leaving underlying resources alive until garbage collection. The original response is now disposed as soon as it is replaced (unless the fake returns the same instance). See #8.

3.1.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 11 Aug 22:55
4d54d25

3.1.0

Added

  • FakeHttpClient factory for unit testing. New public static class FakeHttpClient that creates an HttpClient (FakeHttpClient.Create) or its underlying HttpMessageHandler (FakeHttpClient.CreateHandler) already wired with fake responses — with no need for dependency injection, IHostEnvironment, or IHttpClientBuilder. This makes it possible to fake external APIs consumed through an HttpClient directly in unit tests, instead of mocking the API interface.
    • Fakes are enabled by default in the factory.
    • Fakes are configured exactly like during application execution: all FromRequest/FromResponse methods (sync and async) and the class-based IFakeResponseFrom* interfaces are supported.
    • Optional serviceProvider parameter, passed through to the fake handlers so fakes can resolve services via DI. When omitted, an empty provider (that always returns null) is used.
    • Optional defaultResponse parameter that simulates the "real" external API response when no FromRequest fake matches — enabling FromResponse fakes and status-code assertions.
    • Requests that don't match any fake throw a descriptive InvalidOperationException by default, so unexpected calls fail tests loudly.
    • Verified to work with typed clients, a mocked IHttpClientFactory, and Refit-generated clients.

Documentation

  • Added a "Using Fresp in unit tests" section to the README covering the FakeHttpClient factory, dependency injection, unmatched-request behavior, usage with a mocked IHttpClientFactory, and Refit integration.

Changed

  • Updated dependencies:
    • .NET 10 target: Microsoft.Extensions.Http and Microsoft.Extensions.Hosting.Abstractions 10.0.2 → 10.0.11.
    • .NET 9 target: Microsoft.Extensions.Http and Microsoft.Extensions.Hosting.Abstractions 9.0.11 → 9.0.19.
    • .NET 8 target: unchanged (8.0.1).

Notes

  • No breaking changes. Existing application-execution usage (AddFakeHandler on IHttpClientBuilder) is unchanged.

3.0.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 06 Apr 22:59
e40bbf6
  • Add DI support to fake handlers via IServiceProvider

2.3.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 21 Jan 12:28
a4bbf79
  • Added option to execute on production environments.

2.2.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 19 Jan 23:14
daeafe3
  • Updated to .NET10

2.0.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 14 Feb 22:56
baf8f2c

2.0.0 🚀

  • Added new fake responses from responses
  • Added option do add fake responses from classes
  • fixed some classes with divergent names

1.0.0

Choose a tag to compare

@Adolfok3 Adolfok3 released this 10 Feb 22:31
ce9d063
  • First Impl