Add file/stream/bytes responders#129
Merged
Merged
Conversation
There was a problem hiding this comment.
InspectCode found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
4b9b464 to
fc69dce
Compare
Coverage Report for CI Build 26687775871Coverage decreased (-1.7%) to 84.482%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Adds RespondsWithFile, RespondsWithStream and RespondsWithBytes to RequestMockBuilder for large/binary payloads. RespondsWithFile opens the file per request and infers content-type from the extension; RespondsWithBytes buffers bytes for multi-invocation; RespondsWithStream documents the single-read caveat. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fc69dce to
d0b3c4f
Compare
This was referenced Jun 1, 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.
Closes #123
Adds three additive, backward-compatible responders to
RequestMockBuilderfor large or binary payloads (file downloads, images, PDFs) without buffering everything into a string.New API
RequestMockResponseBuilder RespondsWithFile(string path, string? contentType = null)— opens the file per request (fresh readable stream for each invocation) and infers the content type from the file extension via a small internal extension→MIME map, defaulting toapplication/octet-streamwhen not supplied. SetsContent-TypeandContent-Length.RequestMockResponseBuilder RespondsWithBytes(byte[] content, string contentType)— buffers the bytes so the mock can safely be invoked multiple times. SetsContent-Type.RequestMockResponseBuilder RespondsWithStream(Stream stream, string contentType)— documents the single-read caveat (aStreamcan only be consumed once); preferRespondsWithBytes/RespondsWithFilefor multi-invocation mocks. SetsContent-Type.Tests
Added a
RespondingWithBinaryPayloadsspec class covering: file downloaded with correct bytes + inferred/explicit content-type, default content-type for unknown extensions, multi-invocation file mock, buffered byte content (single + multi-invocation), stream response, and the documented stream single-read behavior.Notes
Mockly.ApiVerificationTests/ApprovedApiviaAcceptApiChanges.ps1../build.ps1is green (compile, tests, API checks, inspect code) for bothnet472andnet8.0.Do not merge — draft for maintainer review.