Skip to content

feat: allow combining multiple conditions on HttpContent#525

Merged
vbreuss merged 4 commits intomainfrom
topic/feat-allow-combining-multiple-conditions-on-HttpContent
Mar 14, 2026
Merged

feat: allow combining multiple conditions on HttpContent#525
vbreuss merged 4 commits intomainfrom
topic/feat-allow-combining-multiple-conditions-on-HttpContent

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Mar 14, 2026

This PR extends Mockolate’s It.IsHttpContent() matching so multiple body conditions can be combined, and introduces an Exactly() modifier for strict string-body matching.

Key Changes:

  • Allow accumulating multiple HttpContent body matchers (AND semantics) instead of overwriting the previous matcher.
  • Update WithString matching to support .Exactly() for full-body equality and expand tests for new composition scenarios.
  • Update API snapshot expectations to include the new Exactly() method.

@vbreuss vbreuss self-assigned this Mar 14, 2026
Copilot AI review requested due to automatic review settings March 14, 2026 05:32
@vbreuss vbreuss added the enhancement New feature or request label Mar 14, 2026
@github-actions
Copy link

github-actions bot commented Mar 14, 2026

Test Results

    21 files  ±  0      21 suites  ±0   5m 44s ⏱️ -32s
 2 838 tests + 26   2 837 ✅ + 26  1 💤 ±0  0 ❌ ±0 
19 075 runs  +182  19 074 ✅ +182  1 💤 ±0  0 ❌ ±0 

Results for commit 7b7aca6. ± Comparison against base commit 1e8bcd5.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 14, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.73GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.201
[Host] : .NET 10.0.5 (10.0.5, 10.0.526.15411), 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,659.5 ns 8.41 ns 7.03 ns 0.2441 - 3.99 KB
Simple_Moq 181,398.7 ns 752.90 ns 667.43 ns 0.4883 - 14.55 KB
Simple_NSubstitute 5,586.2 ns 31.56 ns 27.98 ns 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6,093.8 ns 22.83 ns 19.06 ns 0.4959 - 8.11 KB
Simple_Imposter 588.9 ns 7.46 ns 6.98 ns 0.2537 0.0029 4.15 KB
Simple_TUnitMocks 2,462.0 ns 66.05 ns 55.16 ns 0.4005 0.0076 6.55 KB

Copy link

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 extends Mockolate’s It.IsHttpContent() matching so multiple body conditions can be combined, and introduces an Exactly() modifier for strict string-body matching.

Changes:

  • Allow accumulating multiple HttpContent body matchers (AND semantics) instead of overwriting the previous matcher.
  • Update WithString matching to support .Exactly() for full-body equality and expand tests for new composition scenarios.
  • Update API snapshot expectations to include the new Exactly() method.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringTests.cs Adds tests for .Exactly() and multiple WithString expectations.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringMatchingTests.cs Adds tests ensuring multiple WithStringMatching expectations are all verified.
Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Source/Mockolate/Web/ItExtensions.HttpContent.cs Switches from a single content matcher to a list of matchers and requires all to match.
Source/Mockolate/Web/ItExtensions.HttpContent.WithString.cs Implements substring matching + adds .Exactly() to require full-body equality.
Source/Mockolate/Internals/Polyfills/StringExtensions.cs Adds NETSTANDARD2_0 polyfill for string.Contains(string, StringComparison).

Copilot AI review requested due to automatic review settings March 14, 2026 07:07
@vbreuss vbreuss enabled auto-merge (squash) March 14, 2026 07:08
@sonarqubecloud
Copy link

Copy link

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

Extends Mockolate’s It.IsHttpContent() matching to support composing multiple body predicates (AND semantics) and adds an Exactly() modifier to switch WithString(...) from substring matching to full-body matching.

Changes:

  • Accumulate multiple HttpContent string-body predicates and require all to match.
  • Add Exactly() to the string-body matcher API and expand tests for strict vs non-strict matching and multi-expectation composition.
  • Update API snapshot expectations for the new Exactly() method.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringTests.cs Adds tests for Exactly() and composed string expectations; updates existing WithString expectations.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringMatchingTests.cs Adds tests verifying multiple wildcard expectations are all enforced.
Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt Updates API snapshot to include IStringContentBodyParameter.Exactly().
Source/Mockolate/Web/ItExtensions.HttpContent.cs Changes matcher storage to support multiple string predicates (AND semantics).
Source/Mockolate/Web/ItExtensions.HttpContent.WithString.cs Implements WithString as substring match by default with an Exactly() modifier for full-body matching; wires Exactly() into wildcard matching too.
Source/Mockolate/Internals/Polyfills/StringExtensions.cs Adds a NETSTANDARD2_0 polyfill for string.Contains(..., StringComparison).

@vbreuss vbreuss merged commit f9b857a into main Mar 14, 2026
16 checks passed
@vbreuss vbreuss deleted the topic/feat-allow-combining-multiple-conditions-on-HttpContent branch March 14, 2026 08:15
@github-actions
Copy link

This is addressed in release v1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow combining multiple conditions on HttpContent

2 participants