-
-
Notifications
You must be signed in to change notification settings - Fork 231
Add method CreateHttpClientFactory #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new CreateHttpClientFactory
API on WireMockServer
to return an IHttpClientFactory
, along with a concrete WireMockHttpClientFactory
implementation and a covering test.
- Adds
CreateHttpClientFactory
method (with optional handlers) and lazy factory initialization - Implements
WireMockHttpClientFactory
forIHttpClientFactory
- Adds a test to verify basic factory functionality under .NET 5+
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/WireMock.Net.Minimal/Server/WireMockServer.cs | Introduce CreateHttpClientFactory , lazy field, remove null checks on Ports /Urls |
src/WireMock.Net.Minimal/Http/WireMockHttpClientFactory.cs | Add primary‐constructor factory class implementing IHttpClientFactory |
test/WireMock.Net.Tests/WireMockServer.Admin.cs | Add a .NET 5+ test for creating and using the HTTP client factory |
Comments suppressed due to low confidence (5)
src/WireMock.Net.Minimal/Server/WireMockServer.cs:126
- The XML doc nests
<param>
inside<summary>
and is missing a<returns>
tag. Extract the<param>
to its own section and add<returns>IHttpClientFactory</returns>
.
/// <summary>
src/WireMock.Net.Minimal/Http/WireMockHttpClientFactory.cs:13
- [nitpick] The
name
parameter is not used in the implementation, which may confuse consumers. Either document that names are ignored or adjust the logic to support named client configurations.
public HttpClient CreateClient(string name)
test/WireMock.Net.Tests/WireMockServer.Admin.cs:569
- No test covers passing custom
DelegatingHandler
instances toCreateHttpClientFactory
. Consider adding a test that verifies handlers are applied as expected when provided.
var factory = server.CreateHttpClientFactory();
src/WireMock.Net.Minimal/Server/WireMockServer.cs:65
- Removing the null-conditional operator on
Ports
may lead to a NullReferenceException ifPorts
is ever null; consider restoring the safe-navigation or ensuringPorts
is always initialized.
public int Port => Ports.FirstOrDefault();
src/WireMock.Net.Minimal/Server/WireMockServer.cs:73
- Similarly, dropping the null-conditional operator on
Urls
can throw ifUrls
is null; either reinstate the null check or guaranteeUrls
is never null.
public string? Url => Urls.FirstOrDefault();
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1325 +/- ##
==========================================
- Coverage 37.50% 37.17% -0.33%
==========================================
Files 175 176 +1
Lines 38872 40858 +1986
==========================================
+ Hits 14579 15190 +611
- Misses 23813 25242 +1429
+ Partials 480 426 -54 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.