Skip to content

fix: do not check type of HttpContent#387

Merged
vbreuss merged 1 commit into
mainfrom
topic/do-not-check-for-stringcontent
Jan 24, 2026
Merged

fix: do not check type of HttpContent#387
vbreuss merged 1 commit into
mainfrom
topic/do-not-check-for-stringcontent

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jan 24, 2026

This pull request fixes an issue where HttpContent parameter matching was overly strict by removing type checking for HttpContent instances. The change allows matching based on content rather than concrete type.

Key Changes:

  • Removed StringContent type check in IsStringContent matcher
  • Replaced direct content reading methods with stream-based reading to support any HttpContent type
  • Added test coverage for non-matching types and type-agnostic content matching

@vbreuss vbreuss self-assigned this Jan 24, 2026
@vbreuss vbreuss added the bug Something isn't working label Jan 24, 2026
Copilot AI review requested due to automatic review settings January 24, 2026 09:32
Copy link
Copy Markdown

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 pull request fixes an issue where HttpContent parameter matching was overly strict by removing type checking for HttpContent instances. The change allows matching based on content rather than concrete type.

Changes:

  • Removed StringContent type check in IsStringContent matcher
  • Replaced direct content reading methods with stream-based reading to support any HttpContent type
  • Added test coverage for non-matching types and type-agnostic content matching

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Source/Mockolate/Web/ItExtensions.HttpContent.IsStringContent.cs Removed type check and switched to stream-based content reading
Source/Mockolate/Web/ItExtensions.HttpContent.IsBinaryContent.cs Switched to stream-based content reading with proper stream position reset
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsStringContentTests.cs Added test verifying ByteArrayContent matches IsStringContent matcher
Tests/Mockolate.Tests/Web/ItExtensionsTests.UriTests.cs Added test for type mismatch scenarios

Comment thread Source/Mockolate/Web/ItExtensions.HttpContent.IsBinaryContent.cs Outdated
Comment thread Tests/Mockolate.Tests/Web/ItExtensionsTests.UriTests.cs
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 24, 2026

Test Results

    14 files  ± 0      14 suites  ±0   6m 12s ⏱️ +45s
 2 317 tests + 4   2 316 ✅ + 4  1 💤 ±0  0 ❌ ±0 
15 524 runs  +28  15 523 ✅ +28  1 💤 ±0  0 ❌ ±0 

Results for commit 35ae701. ± Comparison against base commit 47753ac.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 24, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 3.11GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
[Host] : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.510 μs 0.0129 μs 0.0121 μs 0.2270 - 3.73 KB
Simple_Moq 178.365 μs 0.6747 μs 0.5268 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.560 μs 0.0493 μs 0.0461 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.486 μs 0.0683 μs 0.0606 μs 0.4959 - 8.11 KB

@vbreuss vbreuss force-pushed the topic/do-not-check-for-stringcontent branch from e4fc964 to 35ae701 Compare January 24, 2026 09:42
@vbreuss vbreuss enabled auto-merge (squash) January 24, 2026 09:43
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit 6cf63ba into main Jan 24, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/do-not-check-for-stringcontent branch January 24, 2026 09:47
@github-actions
Copy link
Copy Markdown

This is addressed in release v1.0.2.

@github-actions github-actions Bot added the state: released The issue is released label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants