Skip to content

feat: add WithHeaders parameter match#459

Merged
vbreuss merged 6 commits into
mainfrom
topic/add-withheaders
Feb 6, 2026
Merged

feat: add WithHeaders parameter match#459
vbreuss merged 6 commits into
mainfrom
topic/add-withheaders

Conversation

@vbreuss

@vbreuss vbreuss commented Feb 5, 2026

Copy link
Copy Markdown
Member

This PR adds a new WithHeaders parameter matcher for HTTP content validation in Mockolate. The feature allows users to specify HTTP header expectations when mocking HTTP client calls.

Key Changes:

  • Added HttpHeaderValue class to represent HTTP header values with extensible matching logic
  • Introduced IHttpHeaderParameter<TParameter> interface to enable header expectations on HTTP content parameters
  • Created comprehensive test coverage for single and multiple header matching with case sensitivity rules

@vbreuss vbreuss self-assigned this Feb 5, 2026
@vbreuss vbreuss added the enhancement New feature or request label Feb 5, 2026
Copilot AI review requested due to automatic review settings February 5, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

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 adds a new WithHeaders parameter matcher for HTTP content validation in Mockolate. The feature allows users to specify HTTP header expectations when mocking HTTP client calls.

Changes:

  • Added HttpHeaderValue class to represent HTTP header values with extensible matching logic
  • Introduced IHttpHeaderParameter<TParameter> interface to enable header expectations on HTTP content parameters
  • Created comprehensive test coverage for single and multiple header matching with case sensitivity rules

Reviewed changes

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

Show a summary per file
File Description
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsStringContentTests.cs Reformatted assertion chains for improved readability
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithMediaTypeTests.cs Added tests for media type verification on generic HTTP content
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithHeadersTests.cs Added comprehensive tests for header matching including case sensitivity and multiple header scenarios
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsBinaryContentTests.cs Reformatted assertion chains for improved readability
Tests/Mockolate.Api.Tests/Expected/*.txt Updated API surface documentation to include new header matching interfaces and methods
Source/Mockolate/Web/ItExtensions.cs Added HttpHeadersMatcher class and IHttpHeaderParameter<TParameter> interface for header matching
Source/Mockolate/Web/ItExtensions.HttpContent.cs Implemented header matching functionality in HTTP content parameters and added IsHttpContent() method
Source/Mockolate/Web/HttpHeaderValue.cs Added HttpHeaderValue class with virtual Matches method and implicit string conversion
Source/Mockolate/Internals/Polyfills/StringExtensions.cs Added Split polyfill for .NET Standard 2.0 compatibility

Comment thread Source/Mockolate/Web/ItExtensions.HttpContent.cs Outdated
Comment thread Source/Mockolate/Web/ItExtensions.HttpContent.cs Outdated
Copilot AI review requested due to automatic review settings February 5, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

Source/Mockolate/Web/ItExtensions.cs:1

  • The TrimStart method is called with a single space character, but HTTP header values can contain other whitespace characters (tabs, multiple spaces). Use TrimStart() without arguments to remove all leading whitespace according to HTTP standards.
using System;

Comment thread Source/Mockolate/Web/ItExtensions.cs Outdated
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.61GHz, 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.472 μs 0.0097 μs 0.0076 μs 0.2270 - 3.73 KB
Simple_Moq 176.955 μs 0.4263 μs 0.3559 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.759 μs 0.0385 μs 0.0341 μs 0.5493 0.0076 9.09 KB
Simple_FakeItEasy 6.479 μs 0.0298 μs 0.0279 μs 0.4959 - 8.11 KB

Copilot AI review requested due to automatic review settings February 5, 2026 17:51
@vbreuss vbreuss force-pushed the topic/add-withheaders branch from f95022a to de4f779 Compare February 5, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Comment thread Source/Mockolate/Web/HttpHeaderValue.cs
Comment thread Source/Mockolate/Web/ItExtensions.cs Outdated
@vbreuss vbreuss enabled auto-merge (squash) February 5, 2026 17:52
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown

Test Results

    21 files  ±  0      21 suites  ±0   5m 35s ⏱️ -23s
 2 534 tests + 18   2 533 ✅ + 18  1 💤 ±0  0 ❌ ±0 
17 003 runs  +126  17 002 ✅ +126  1 💤 ±0  0 ❌ ±0 

Results for commit f29c6db. ± Comparison against base commit c1fab83.

♻️ This comment has been updated with latest results.

Comment thread Source/Mockolate/Web/ItExtensions.HttpContent.cs Outdated
@sonarqubecloud

sonarqubecloud Bot commented Feb 6, 2026

Copy link
Copy Markdown

@vbreuss vbreuss merged commit c9b806b into main Feb 6, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-withheaders branch February 6, 2026 08:34
@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown

This is addressed in release v1.3.0.

@github-actions github-actions Bot added the state: released The issue is released label Feb 7, 2026
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.

2 participants