refactor: extract shared FakeHttpClientFactory and remove duplicated JsonResponse helpers#917
Merged
Aaronontheweb merged 3 commits intoMay 7, 2026
Conversation
Five test files each defined identical StubHttpClientFactory and StubHttpMessageHandler nested classes. Replace all five with a shared FakeHttpClientFactory in Netclaw.Tests.Utilities that wraps the existing FakeHttpMessageHandler. Adds Microsoft.Extensions.Http package reference to Netclaw.Tests.Utilities so IHttpClientFactory is resolvable in the utilities project. Closes netclaw-dev#911
…eHandler.JsonResponse Four test files each defined a private JsonResponse(object body, ...) helper that was a verbatim copy of FakeHttpMessageHandler.JsonResponse<T>. Remove all four and update call sites to use the shared static method directly. Also drop the now-orphaned System.Net and System.Text using directives.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FakeHttpClientFactorytoNetclaw.Tests.Utilities— a sharedIHttpClientFactoryimplementation that wrapsFakeHttpMessageHandler, replacing five identicalStubHttpClientFactory/StubHttpMessageHandlernested class pairs spread across test filesJsonResponse(object body, ...)helpers in the same test files with direct calls toFakeHttpMessageHandler.JsonResponse<T>, which already existed for this purposeusing System.Netandusing System.Textdirectives from the affected filesMicrosoft.Extensions.Httppackage reference toNetclaw.Tests.Utilities.csproj(via central package management) soIHttpClientFactoryresolves in the utilities assemblyCloses #911
Files changed
src/Netclaw.Tests.Utilities/FakeHttpClientFactory.cs— new shared factorysrc/Netclaw.Tests.Utilities/Netclaw.Tests.Utilities.csproj—Microsoft.Extensions.Httpreferencesrc/Netclaw.Cli.Tests/Cli/DaemonApiAuthenticationTests.cs— removed stubs and local helpersrc/Netclaw.Cli.Tests/Doctor/ContextWindowDoctorCheckTests.cs— removed stubs and local helpersrc/Netclaw.Cli.Tests/Doctor/McpServersDoctorCheckTests.cs— removed stubs and local helpersrc/Netclaw.Cli.Tests/Mcp/McpCommandTests.cs— removed stubs and local helperTest plan
dotnet testpasses forNetclaw.Cli.Tests— 47/47 tests greendotnet slopwatch analyze— 0 issuesAdd-FileHeaders.ps1 -Verify— all headers present