Skip to content

Conversation

StefH
Copy link
Collaborator

@StefH StefH commented Jul 7, 2025

No description provided.

@StefH StefH requested a review from Copilot July 7, 2025 19:53
@StefH StefH self-assigned this Jul 7, 2025
@StefH StefH added the feature label Jul 7, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 for IHttpClientFactory
  • 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 to CreateHttpClientFactory. 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 if Ports is ever null; consider restoring the safe-navigation or ensuring Ports 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 if Urls is null; either reinstate the null check or guarantee Urls is never null.
    public string? Url => Urls.FirstOrDefault();

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 41.93548% with 18 lines in your changes missing coverage. Please review.

Project coverage is 37.17%. Comparing base (35cd06b) to head (1f6d0c2).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/WireMock.Net.Minimal/Server/WireMockServer.cs 34.78% 15 Missing ⚠️
...Mock.Net.Minimal/Http/WireMockHttpClientFactory.cs 62.50% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StefH StefH merged commit 6c61f87 into master Jul 8, 2025
10 of 11 checks passed
@StefH StefH deleted the IHttpClientFactory branch July 8, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant