Add GetMessageHandler() to HttpMock#94
Merged
dennisdoomen merged 3 commits intomainfrom Apr 10, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/dennisdoomen/mockly/sessions/fcb676b8-3631-4914-b34c-a17512d79051 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dennisdoomen/mockly/sessions/fcb676b8-3631-4914-b34c-a17512d79051 Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
dennisdoomen
requested changes
Apr 10, 2026
| public class WhenGettingMessageHandler | ||
| { | ||
| [Fact] | ||
| public async Task GetMessageHandler_returns_handler_that_intercepts_requests() |
Owner
There was a problem hiding this comment.
Suggested change
| public async Task GetMessageHandler_returns_handler_that_intercepts_requests() | |
| public async Task Can_return_a_message_handler_that_intercepts_requests() |
Copilot created this pull request from a session on behalf of
dennisdoomen
April 10, 2026 07:30
View session
Agent-Logs-Url: https://github.com/dennisdoomen/mockly/sessions/7d566c31-4f98-4a1e-81c6-09037d9cbdeb Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Coverage Report for CI Build 24231931000Coverage increased (+0.04%) to 83.649%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
|
||
| var handler = mock.GetMessageHandler(); | ||
|
|
||
| using var client = new HttpClient(handler) |
dennisdoomen
approved these changes
Apr 10, 2026
This was referenced Apr 14, 2026
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
Adds a
GetMessageHandler()method toHttpMockalongside the existingGetClient()andGetClientFactory()methods. It returns the underlyingMockHttpMessageHandlertyped asHttpMessageHandler, allowing users to wire the mock handler directly into anHttpClientor other infrastructure that accepts anHttpMessageHandler.Changes
Mockly/HttpMock.cs: AddedGetMessageHandler()public method with XML doc comment andCA1024suppression (consistent withGetClient()andGetClientFactory())Mockly.Specs/HttpMockSpecs.cs: AddedWhenGettingMessageHandlertest class with a passing testMockly.ApiVerificationTests/ApprovedApi/net8.0.verified.txt: Added new method to approved API surfaceMockly.ApiVerificationTests/ApprovedApi/net472.verified.txt: Added new method to approved API surfacewebsite/docs/quick-start.md: Added a new "Using a Raw HttpMessageHandler" sectionwebsite/docs/usage.md: Added a section comparing all three wiring options (GetClient,GetClientFactory,GetMessageHandler)Usage