feat: add WithHeaders parameter match#459
Conversation
There was a problem hiding this comment.
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
HttpHeaderValueclass 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 |
There was a problem hiding this comment.
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
TrimStartmethod is called with a single space character, but HTTP header values can contain other whitespace characters (tabs, multiple spaces). UseTrimStart()without arguments to remove all leading whitespace according to HTTP standards.
using System;
🚀 Benchmark ResultsDetails
|
f95022a to
de4f779
Compare
|
|
This is addressed in release v1.3.0. |



This PR adds a new
WithHeadersparameter matcher for HTTP content validation in Mockolate. The feature allows users to specify HTTP header expectations when mocking HTTP client calls.Key Changes:
HttpHeaderValueclass to represent HTTP header values with extensible matching logicIHttpHeaderParameter<TParameter>interface to enable header expectations on HTTP content parametersWithHeaderstoHttpRequestMessageparameter #458