Skip to content

refactor: simplify web extensions#733

Merged
vbreuss merged 1 commit into
mainfrom
topic/simplify-web-extensions
Apr 30, 2026
Merged

refactor: simplify web extensions#733
vbreuss merged 1 commit into
mainfrom
topic/simplify-web-extensions

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Apr 30, 2026

This pull request makes several improvements and bug fixes related to parameter matching logic and code cleanup in the Mockolate web testing utilities. The most important changes are focused on making the parameter matching logic stricter and simplifying the codebase.

Parameter Matching Logic

  • Updated the implementation of IParameter.Matches(object?) in both ItExtensions.HttpContent.cs and ItExtensions.Uri.cs to only return true if the value is of the expected type (HttpContent or Uri), making the matching logic stricter and preventing unintended matches with null values.
  • Simplified the URI pattern matching logic in ItExtensions.Uri.cs to only check the pattern against the URI string, removing redundant checks for trailing slashes and unnecessary wildcard matching.

Code Cleanup

  • Removed an unnecessary using directive for a polyfills namespace in ItExtensions.Uri.cs when targeting .NET Standard 2.0, as it is no longer needed.
  • Replaced the use of collection initializer syntax with explicit instantiation of a List<string?> in ItExtensions.HttpRequestMessage.cs for clarity and compatibility.

@vbreuss vbreuss self-assigned this Apr 30, 2026
@vbreuss vbreuss enabled auto-merge (squash) April 30, 2026 19:37
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ±0      21 suites  ±0   9m 42s ⏱️ +46s
 3 936 tests ±0   3 934 ✅ ±0  2 💤 ±0  0 ❌ ±0 
25 570 runs  ±0  25 566 ✅ ±0  4 💤 ±0  0 ❌ ±0 

Results for commit 43f2c1c. ± Comparison against base commit 11710b5.

@vbreuss vbreuss merged commit b0d1248 into main Apr 30, 2026
16 checks passed
@vbreuss vbreuss deleted the topic/simplify-web-extensions branch April 30, 2026 19:44
@github-actions
Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.203
[Host] : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

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

Method Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Event_Mockolate 335.0 ns 2.61 ns 2.44 ns 1.00 0.01 0.1254 0.0005 2.05 KB 1.00
Event_Moq 15,623.3 ns 49.87 ns 41.64 ns 46.64 0.35 0.7324 - 12.51 KB 6.09
Event_NSubstitute 5,658.6 ns 9.56 ns 7.98 ns 16.89 0.12 0.5493 0.0076 9.05 KB 4.40
Event_FakeItEasy 215,939.3 ns 3,099.69 ns 2,899.46 ns 644.70 9.52 0.7324 0.4883 15.39 KB 7.49
Event_Imposter 1,327.2 ns 8.80 ns 8.23 ns 3.96 0.04 0.5379 0.0153 8.8 KB 4.29
Event_TUnitMocks 175.4 ns 0.67 ns 0.59 ns 0.52 0.00 0.0837 0.0002 1.37 KB 0.67
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.203
[Host] : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

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

Method N Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Indexer_Mockolate 1 1,027.8 ns 23.61 ns 22.09 ns 1.00 0.03 0.2460 0.0019 4.03 KB 1.00
Indexer_Moq 1 170,639.8 ns 1,280.35 ns 1,069.15 ns 166.10 3.62 0.9766 0.4883 20.37 KB 5.05
Indexer_NSubstitute 1 8,887.4 ns 166.23 ns 155.49 ns 8.65 0.23 0.7782 - 12.84 KB 3.18
Indexer_FakeItEasy 1 10,321.4 ns 85.55 ns 80.02 ns 10.05 0.22 0.8392 0.0305 13.88 KB 3.44
Indexer_Imposter 1 960.8 ns 17.46 ns 16.33 ns 0.94 0.02 0.3147 0.0048 5.16 KB 1.28
Indexer_Mockolate 10 2,607.8 ns 51.77 ns 48.43 ns 1.00 0.03 0.3090 - 5.09 KB 1.00
Indexer_Moq 10 180,972.9 ns 925.95 ns 773.21 ns 69.42 1.30 1.7090 1.4648 29.89 KB 5.88
Indexer_NSubstitute 10 21,359.6 ns 301.54 ns 267.30 ns 8.19 0.18 1.5564 0.0305 25.63 KB 5.04
Indexer_FakeItEasy 10 21,273.2 ns 267.78 ns 250.48 ns 8.16 0.18 2.1667 0.0610 35.47 KB 6.97
Indexer_Imposter 10 2,215.9 ns 71.74 ns 67.10 ns 0.85 0.03 0.4845 0.0076 7.97 KB 1.57
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.203
[Host] : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

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

Method N Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Method_Mockolate 1 480.9 ns 10.56 ns 9.36 ns 1.00 0.03 0.1411 0.0010 2.32 KB 1.00
Method_Moq 1 183,181.8 ns 792.70 ns 702.71 ns 381.08 7.40 0.4883 - 14.73 KB 6.35
Method_NSubstitute 1 5,724.1 ns 60.17 ns 56.28 ns 11.91 0.25 0.5569 0.0076 9.12 KB 3.93
Method_FakeItEasy 1 6,111.6 ns 47.02 ns 43.98 ns 12.71 0.26 0.4959 - 8.11 KB 3.50
Method_Imposter 1 612.2 ns 12.67 ns 11.24 ns 1.27 0.03 0.2470 0.0029 4.04 KB 1.74
Method_TUnitMocks 1 761.6 ns 9.87 ns 9.23 ns 1.58 0.04 0.1774 0.0010 2.9 KB 1.25
Method_Mockolate 10 774.5 ns 18.76 ns 16.63 ns 1.00 0.03 0.1545 0.0010 2.53 KB 1.00
Method_Moq 10 188,592.6 ns 1,114.69 ns 1,042.68 ns 243.61 5.17 0.9766 0.7324 18.64 KB 7.36
Method_NSubstitute 10 9,244.5 ns 99.79 ns 93.34 ns 11.94 0.27 0.7324 0.0153 12.07 KB 4.77
Method_FakeItEasy 10 9,992.1 ns 73.78 ns 65.40 ns 12.91 0.28 0.9766 0.0305 16.05 KB 6.34
Method_Imposter 10 1,257.9 ns 15.36 ns 12.83 ns 1.62 0.04 0.3376 0.0057 5.52 KB 2.18
Method_TUnitMocks 10 1,828.5 ns 24.93 ns 23.32 ns 2.36 0.06 0.2747 0.0019 4.49 KB 1.77
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.203
[Host] : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v4

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

Method N Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Property_Mockolate 1 674.0 ns 9.70 ns 8.59 ns 1.00 0.02 0.1049 - 2.58 KB 1.00
Property_Moq 1 11,480.1 ns 42.65 ns 39.90 ns 17.03 0.22 0.3662 - 10.39 KB 4.03
Property_NSubstitute 1 7,966.8 ns 13.75 ns 12.86 ns 11.82 0.15 0.4578 - 11.45 KB 4.44
Property_FakeItEasy 1 8,089.7 ns 32.92 ns 30.79 ns 12.00 0.15 0.4578 - 11.25 KB 4.36
Property_Imposter 1 557.3 ns 19.43 ns 18.17 ns 0.83 0.03 0.1268 0.0010 3.13 KB 1.21
Property_TUnitMocks 1 867.6 ns 5.70 ns 5.33 ns 1.29 0.02 0.1020 - 2.51 KB 0.97
Property_Mockolate 10 1,385.3 ns 3.97 ns 3.51 ns 1.00 0.00 0.1240 - 3.07 KB 1.00
Property_Moq 10 18,234.2 ns 45.42 ns 42.49 ns 13.16 0.04 0.7324 - 18.28 KB 5.95
Property_NSubstitute 10 17,269.9 ns 38.39 ns 32.06 ns 12.47 0.04 0.8545 - 21.08 KB 6.87
Property_FakeItEasy 10 19,024.4 ns 267.12 ns 249.86 ns 13.73 0.18 1.2512 0.0305 30.8 KB 10.03
Property_Imposter 10 1,442.6 ns 7.89 ns 7.38 ns 1.04 0.01 0.1888 0.0019 4.67 KB 1.52
Property_TUnitMocks 10 2,749.6 ns 7.30 ns 6.47 ns 1.98 0.01 0.1869 - 4.66 KB 1.52
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz (Max: 2.79GHz), 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.203
[Host] : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v4

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

Method Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Callback_Mockolate 474.4 ns 12.18 ns 10.80 ns 1.00 0.03 0.0792 - 1.96 KB 1.00
Callback_Moq 70,271.0 ns 264.25 ns 220.66 ns 148.20 3.35 0.2441 - 8.88 KB 4.53
Callback_NSubstitute 4,360.6 ns 26.65 ns 24.93 ns 9.20 0.21 0.3128 0.0076 7.74 KB 3.95
Callback_FakeItEasy 4,772.9 ns 19.27 ns 17.08 ns 10.07 0.23 0.2747 - 6.8 KB 3.47
Callback_Imposter 474.5 ns 14.03 ns 13.12 ns 1.00 0.03 0.0963 - 2.38 KB 1.22
Callback_TUnitMocks 766.9 ns 14.18 ns 13.27 ns 1.62 0.05 0.1068 0.0010 2.63 KB 1.34

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant