Skip to content

coverage: add fast-path and fallback tests for property, indexer, event, and method verification#735

Merged
vbreuss merged 1 commit into
mainfrom
topic/add-fast-path-and-fallback-tests-for-property,-indexer,-event,-and-method-verification
Apr 30, 2026
Merged

coverage: add fast-path and fallback tests for property, indexer, event, and method verification#735
vbreuss merged 1 commit into
mainfrom
topic/add-fast-path-and-fallback-tests-for-property,-indexer,-event,-and-method-verification

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Apr 30, 2026

This pull request adds comprehensive new tests to the Mockolate.Tests/Verify suite, focusing on verifying the correct behavior of interaction verification, fast-path property/indexer/event handling, and record sorting logic. These tests ensure that verification methods mark interactions as verified, that buffer and fallback logic is exercised, and that error messages are properly formatted.

New test coverage for fast-path and fallback verification:

  • Adds VerifyPropertyFastPathTests to test property getter/setter verification, including correct error messages, predicate logic, and buffer handling.
  • Adds IndexerFastPathTests to test indexer getter/setter verification, including error messages and value matching.
  • Adds SubscribedToFastPathTests and UnsubscribedFromFastPathTests to verify event subscription and unsubscription handling, including buffer and fallback logic.
  • Adds VerifyMethodFallbackTests to ensure method verification works when fast buffers are not present.

Enhancements to verification result mutation tests:

  • Adds tests in VerificationResultMutationTests to ensure that both awaitable and synchronous verification methods mark matching interactions as verified, including when fast-count sources are absent.
  • Adds a test to verify that matching records are sorted by sequence before being returned, ensuring correct order even with out-of-sequence buffers.
  • Introduces a custom OutOfOrderBuffer test helper to simulate out-of-sequence interaction records for sorting tests.

@vbreuss vbreuss self-assigned this Apr 30, 2026
@vbreuss vbreuss added the coverage Additional tests for edge cases or improvement of test coverage label Apr 30, 2026
@vbreuss vbreuss enabled auto-merge (squash) April 30, 2026 19:53
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ±  0      21 suites  ±0   9m 32s ⏱️ +23s
 3 955 tests + 19   3 953 ✅ + 19  2 💤 ±0  0 ❌ ±0 
25 703 runs  +133  25 699 ✅ +133  4 💤 ±0  0 ❌ ±0 

Results for commit f634d9a. ± Comparison against base commit b0d1248.

@vbreuss vbreuss merged commit b0a4f6c into main Apr 30, 2026
16 checks passed
@vbreuss vbreuss deleted the topic/add-fast-path-and-fallback-tests-for-property,-indexer,-event,-and-method-verification branch April 30, 2026 20:01
@github-actions
Copy link
Copy Markdown

🚀 Benchmark Results

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 Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Event_Mockolate 345.5 ns 1.72 ns 1.52 ns 1.00 0.01 0.1254 0.0005 2.05 KB 1.00
Event_Moq 13,781.1 ns 80.26 ns 71.15 ns 39.89 0.26 0.7324 - 12.51 KB 6.09
Event_NSubstitute 5,210.3 ns 20.91 ns 17.46 ns 15.08 0.08 0.5493 0.0076 9.05 KB 4.40
Event_FakeItEasy 217,992.8 ns 408.10 ns 318.62 ns 630.94 2.83 0.4883 - 15.35 KB 7.47
Event_Imposter 1,310.6 ns 3.93 ns 3.67 ns 3.79 0.02 0.5379 0.0153 8.8 KB 4.29
Event_TUnitMocks 172.2 ns 1.20 ns 1.12 ns 0.50 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,023.1 ns 20.79 ns 19.45 ns 1.00 0.03 0.2460 0.0019 4.03 KB 1.00
Indexer_Moq 1 166,880.5 ns 1,704.66 ns 1,511.13 ns 163.16 3.30 0.9766 0.4883 20.37 KB 5.05
Indexer_NSubstitute 1 8,680.7 ns 90.17 ns 79.93 ns 8.49 0.17 0.7782 - 12.78 KB 3.17
Indexer_FakeItEasy 1 9,880.3 ns 89.08 ns 83.33 ns 9.66 0.19 0.8392 0.0305 13.88 KB 3.44
Indexer_Imposter 1 884.7 ns 8.58 ns 7.61 ns 0.87 0.02 0.3147 0.0048 5.16 KB 1.28
Indexer_Mockolate 10 2,496.2 ns 40.84 ns 36.20 ns 1.00 0.02 0.3090 - 5.09 KB 1.00
Indexer_Moq 10 178,386.4 ns 1,284.11 ns 1,201.16 ns 71.48 1.10 1.7090 1.4648 29.89 KB 5.88
Indexer_NSubstitute 10 21,195.0 ns 190.44 ns 178.14 ns 8.49 0.14 1.5564 0.0305 25.58 KB 5.03
Indexer_FakeItEasy 10 21,200.6 ns 175.23 ns 136.81 ns 8.49 0.13 2.1667 0.0610 35.47 KB 6.97
Indexer_Imposter 10 2,088.5 ns 23.90 ns 21.19 ns 0.84 0.01 0.4845 0.0076 7.97 KB 1.57
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
Method_Mockolate 1 445.8 ns 1.97 ns 1.75 ns 1.00 0.01 0.1416 0.0010 2.32 KB 1.00
Method_Moq 1 132,297.2 ns 739.64 ns 655.67 ns 296.79 1.81 0.4883 - 14.58 KB 6.28
Method_NSubstitute 1 5,259.8 ns 32.97 ns 29.22 ns 11.80 0.08 0.5569 0.0076 9.12 KB 3.93
Method_FakeItEasy 1 5,291.7 ns 33.82 ns 31.64 ns 11.87 0.08 0.4959 - 8.11 KB 3.50
Method_Imposter 1 550.0 ns 4.12 ns 3.86 ns 1.23 0.01 0.2470 0.0029 4.04 KB 1.74
Method_TUnitMocks 1 693.5 ns 2.70 ns 2.11 ns 1.56 0.01 0.1774 0.0010 2.9 KB 1.25
Method_Mockolate 10 731.5 ns 5.42 ns 5.07 ns 1.00 0.01 0.1545 0.0010 2.53 KB 1.00
Method_Moq 10 136,883.6 ns 572.32 ns 507.35 ns 187.15 1.42 0.9766 0.7324 18.48 KB 7.30
Method_NSubstitute 10 7,910.6 ns 55.28 ns 49.00 ns 10.82 0.10 0.7324 0.0153 12.07 KB 4.77
Method_FakeItEasy 10 8,394.4 ns 49.33 ns 46.15 ns 11.48 0.10 0.9766 0.0305 16.05 KB 6.34
Method_Imposter 10 1,136.5 ns 3.68 ns 3.44 ns 1.55 0.01 0.3376 0.0057 5.52 KB 2.18
Method_TUnitMocks 10 1,771.1 ns 7.62 ns 6.76 ns 2.42 0.02 0.2747 0.0019 4.49 KB 1.77
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
Property_Mockolate 1 528.6 ns 4.06 ns 3.80 ns 1.00 0.01 0.1574 0.0010 2.58 KB 1.00
Property_Moq 1 12,192.1 ns 116.44 ns 108.92 ns 23.07 0.26 0.6104 - 10.5 KB 4.07
Property_NSubstitute 1 7,456.7 ns 37.05 ns 32.84 ns 14.11 0.11 0.6943 0.0076 11.45 KB 4.44
Property_FakeItEasy 1 8,432.5 ns 22.23 ns 20.79 ns 15.95 0.12 0.6866 - 11.24 KB 4.36
Property_Imposter 1 435.9 ns 8.07 ns 7.15 ns 0.82 0.01 0.1912 0.0019 3.13 KB 1.21
Property_TUnitMocks 1 708.2 ns 2.29 ns 1.91 ns 1.34 0.01 0.1526 0.0010 2.51 KB 0.97
Property_Mockolate 10 1,015.5 ns 6.69 ns 5.22 ns 1.00 0.01 0.1869 - 3.07 KB 1.00
Property_Moq 10 18,973.9 ns 43.42 ns 33.90 ns 18.68 0.10 1.0986 - 18.39 KB 5.99
Property_NSubstitute 10 17,406.7 ns 100.58 ns 94.09 ns 17.14 0.12 1.2817 0.0305 21.08 KB 6.87
Property_FakeItEasy 10 19,793.3 ns 71.20 ns 63.12 ns 19.49 0.11 1.8616 - 30.81 KB 10.03
Property_Imposter 10 1,083.8 ns 8.85 ns 8.28 ns 1.07 0.01 0.2842 0.0019 4.67 KB 1.52
Property_TUnitMocks 10 2,099.7 ns 8.94 ns 7.92 ns 2.07 0.01 0.2823 - 4.66 KB 1.52
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.87GHz, 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
Callback_Mockolate 416.0 ns 1.93 ns 1.71 ns 1.00 0.01 0.1197 - 1.96 KB 1.00
Callback_Moq 71,724.3 ns 976.47 ns 865.62 ns 172.40 2.12 0.4883 0.2441 8.88 KB 4.53
Callback_NSubstitute 4,265.7 ns 94.90 ns 88.77 ns 10.25 0.21 0.4730 0.0076 7.74 KB 3.95
Callback_FakeItEasy 4,622.1 ns 115.02 ns 107.59 ns 11.11 0.25 0.4120 0.0153 6.81 KB 3.47
Callback_Imposter 405.4 ns 7.20 ns 6.01 ns 0.97 0.01 0.1454 0.0010 2.38 KB 1.22
Callback_TUnitMocks 648.1 ns 5.46 ns 5.10 ns 1.56 0.01 0.1602 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

coverage Additional tests for edge cases or improvement of test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant