Skip to content

coverage: add missing HttpClient tests#464

Merged
vbreuss merged 2 commits into
mainfrom
topic/add-missing-httpcontent-tests
Feb 7, 2026
Merged

coverage: add missing HttpClient tests#464
vbreuss merged 2 commits into
mainfrom
topic/add-missing-httpcontent-tests

Conversation

@vbreuss

@vbreuss vbreuss commented Feb 7, 2026

Copy link
Copy Markdown
Member

Adds missing test coverage around HttpClient/web matchers, especially for repeated matcher calls and additional edge cases.

Key Changes:

  • Added new theory-based test cases for repeated .WithQuery(...) / .WithHeaders(...) usage and additional negative cases.
  • Added a monitoring test for It.IsHttpRequestMessage().Monitor(...) and a guard-rail test for HttpClient setup without a mockable handler.
  • Simplified query/form parsing by removing a redundant length check.

@vbreuss vbreuss self-assigned this Feb 7, 2026
@vbreuss vbreuss added the coverage Additional tests for edge cases or improvement of test coverage label Feb 7, 2026
Copilot AI review requested due to automatic review settings February 7, 2026 17:58

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

Adds missing test coverage around HttpClient/web matchers, especially for repeated matcher calls and additional edge cases.

Changes:

  • Added new theory-based test cases for repeated .WithQuery(...) / .WithHeaders(...) usage and additional negative cases.
  • Added a monitoring test for It.IsHttpRequestMessage().Monitor(...) and a guard-rail test for HttpClient setup without a mockable handler.
  • Simplified query/form parsing by removing a redundant length check.

Reviewed changes

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

Show a summary per file
File Description
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsUriTests.WithQueryTests.cs Adds coverage for repeated .WithQuery(...) chaining and adds an extra negative query-string case.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpRequestMessageTests.cs Adds monitoring coverage for It.IsHttpRequestMessage() with a captured IParameterMonitor<>.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpRequestMessageTests.WithHeadersTests.cs Adds coverage for repeated .WithHeaders(...) chaining on request messages.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpRequestMessageTests.WhoseContentIsTests.cs Adds coverage for verifying both media type and content in WhoseContentIs(...).
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringTests.cs Renames tests for clarity and adds an additional negative equality case.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithStringMatchingTests.cs Renames tests for clarity and removes an unused using.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithHeadersTests.cs Adds coverage for repeated .WithHeaders(...) chaining and expands string-header test cases.
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithFormDataTests.cs Adds negative form-data cases to improve matcher coverage.
Tests/Mockolate.Tests/Web/HttpClientExtensionsTests.cs Adds a test asserting a MockException when setting up HttpClient without a mockable handler.
Source/Mockolate/Web/ItExtensions.cs Simplifies query parsing filter logic.
Source/Mockolate/Web/ItExtensions.HttpContent.cs Simplifies form/query parsing filter logic for content matchers.

Comment thread Tests/Mockolate.Tests/Web/ItExtensionsTests.IsUriTests.WithQueryTests.cs Outdated
Comment thread Tests/Mockolate.Tests/Web/ItExtensionsTests.IsUriTests.WithQueryTests.cs Outdated
Comment thread Tests/Mockolate.Tests/Web/ItExtensionsTests.IsUriTests.WithQueryTests.cs Outdated
@vbreuss vbreuss enabled auto-merge (squash) February 7, 2026 18:02
@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.45GHz, 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.493 μs 0.0114 μs 0.0095 μs 0.2270 - 3.73 KB
Simple_Moq 177.175 μs 1.1390 μs 1.0097 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.649 μs 0.0590 μs 0.0552 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.420 μs 0.0201 μs 0.0188 μs 0.4959 - 8.11 KB

@sonarqubecloud

sonarqubecloud Bot commented Feb 7, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown

Test Results

    21 files  ±  0      21 suites  ±0   5m 6s ⏱️ -29s
 2 707 tests + 52   2 706 ✅ + 52  1 💤 ±0  0 ❌ ±0 
18 165 runs  +335  18 164 ✅ +335  1 💤 ±0  0 ❌ ±0 

Results for commit c1fe50a. ± Comparison against base commit ec1859d.

This pull request removes 27 and adds 79 tests. Note that renamed tests count towards both.
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ ShouldVerifyStringHeaders
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_IgnoringCase_ShouldCheckForCaseInsensitiveMatchingWildcard(body: "foo", pattern: ".a.", expectSuccess: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_IgnoringCase_ShouldCheckForCaseInsensitiveMatchingWildcard(body: "foo", pattern: "F[aeiou]*", expectSuccess: True)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_IgnoringCase_ShouldCheckForCaseInsensitiveMatchingWildcard(body: "foo", pattern: "f[aeiou]*", expectSuccess: True)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_ShouldCheckForMatchingWildcard(body: "foo", pattern: ".a.", expectSuccess: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_ShouldCheckForMatchingWildcard(body: "foo", pattern: "F[aeiou]*", expectSuccess: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_ShouldCheckForMatchingWildcard(body: "foo", pattern: "f[aeiou]*", expectSuccess: True)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_ShouldUseProvidedOptions
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_AsRegex_ShouldUseTimeout
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithStringMatchingTests ‑ WithBodyMatching_IgnoringCase_ShouldCheckForCaseInsensitiveMatchingWildcard(body: "foo", pattern: "*", expectSuccess: True)
…
Mockolate.Tests.Web.HttpClientExtensionsTests ‑ SendAsync_WithoutMockedHttpMessageHandler_ShouldThrowMockException
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ Exactly_ShouldOnlyMatchWhenAllParametersAreChecked(expectSuccess: False, rawValues: ["z", "567", "x", "123", "x", ···])
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ Exactly_ShouldOnlyMatchWhenAllParametersAreChecked(expectSuccess: False, rawValues: ["z", "567", "x", "123", "x", ┬╖┬╖┬╖])
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ WithFormDataString_ShouldVerifyParameters(values: "x=123&y=432", expectMatch: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ WithFormDataString_ShouldVerifyParameters(values: "y=432&x=123", expectMatch: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ MultipleCalls_ShouldVerifyKeyValueHeaders(key1: "x-myHeader1", value1: "foo", key2: "x-myHeader2", value2: "baz", expectSuccess: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ MultipleCalls_ShouldVerifyKeyValueHeaders(key1: "x-myHeader1", value1: "foo", key2: "x-myHeader3", value2: "baz", expectSuccess: True)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ MultipleCalls_ShouldVerifyKeyValueHeaders(key1: "x-myHeader2", value1: "baz", key2: "x-myHeader1", value2: "foo", expectSuccess: False)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ MultipleCalls_ShouldVerifyKeyValueHeaders(key1: "x-myHeader3", value1: "baz", key2: "x-myHeader1", value2: "foo", expectSuccess: True)
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ MultipleCalls_ShouldVerifyKeyValuePairHeaders(key1: "x-myHeader1", value1: "foo", key2: "x-myHeader2", value2: "baz", expectSuccess: False)
…

@vbreuss vbreuss merged commit bdaa629 into main Feb 7, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-missing-httpcontent-tests branch February 7, 2026 18:07
@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

coverage Additional tests for edge cases or improvement of test coverage state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants