Skip to content

coverage: add MockRegistry.Interactions edge case tests#731

Merged
vbreuss merged 1 commit into
mainfrom
topic/add-`MockRegistry.Interactions`-edge-case-tests
Apr 30, 2026
Merged

coverage: add MockRegistry.Interactions edge case tests#731
vbreuss merged 1 commit into
mainfrom
topic/add-`MockRegistry.Interactions`-edge-case-tests

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Apr 30, 2026

This pull request adds important test coverage for edge cases in the MockRegistry property setup and access logic, ensuring correct behavior when using the optimized member-id lookup paths. It also adds comments clarifying why certain mutation testing suppressions are safe. The changes improve the reliability of the property setup resolution and document subtle implementation details.

Test coverage improvements:

  • Added a test to ensure that when the member-id table contains a null entry, GetPropertyFast correctly falls back to the slower path without throwing an exception.
  • Added a test to verify that when both a member-id-based and a dictionary-based property setup exist for the same property, SetPropertyFast uses the member-id setup in the default scope.
  • Added a test to ensure that when a scenario is active, SetPropertyFast routes to the scenario-specific setup instead of the member-id table setup.

@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:03
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ± 0      21 suites  ±0   9m 0s ⏱️ +5s
 3 886 tests + 3   3 884 ✅ + 3  2 💤 ±0  0 ❌ ±0 
25 220 runs  +21  25 216 ✅ +21  4 💤 ±0  0 ❌ ±0 

Results for commit 51c99e8. ± Comparison against base commit ffa9d1c.

@vbreuss vbreuss merged commit ad6edd9 into main Apr 30, 2026
16 checks passed
@vbreuss vbreuss deleted the topic/add-`MockRegistry.Interactions`-edge-case-tests branch April 30, 2026 19:11
@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 359.8 ns 7.32 ns 6.85 ns 1.00 0.03 0.1254 0.0005 2.05 KB 1.00
Event_Moq 14,616.9 ns 96.50 ns 85.55 ns 40.64 0.78 0.7324 - 12.93 KB 6.29
Event_NSubstitute 5,324.8 ns 43.18 ns 40.39 ns 14.80 0.29 0.5493 0.0076 9.05 KB 4.40
Event_FakeItEasy 229,195.8 ns 706.96 ns 661.29 ns 637.24 11.87 0.7324 0.4883 15.39 KB 7.49
Event_Imposter 1,436.9 ns 22.53 ns 21.08 ns 4.00 0.09 0.5379 0.0153 8.8 KB 4.29
Event_TUnitMocks 176.7 ns 1.71 ns 1.51 ns 0.49 0.01 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.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 N Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Indexer_Mockolate 1 955.5 ns 16.88 ns 14.96 ns 1.00 0.02 0.2460 0.0019 4.03 KB 1.00
Indexer_Moq 1 164,020.6 ns 1,086.61 ns 963.25 ns 171.70 2.75 0.9766 0.4883 20.37 KB 5.05
Indexer_NSubstitute 1 8,463.3 ns 146.68 ns 137.21 ns 8.86 0.19 0.7782 - 12.78 KB 3.17
Indexer_FakeItEasy 1 9,566.6 ns 74.27 ns 69.47 ns 10.01 0.17 0.8392 0.0305 13.88 KB 3.44
Indexer_Imposter 1 875.8 ns 6.76 ns 5.99 ns 0.92 0.02 0.3147 0.0048 5.16 KB 1.28
Indexer_Mockolate 10 2,461.4 ns 16.38 ns 15.32 ns 1.00 0.01 0.3090 - 5.09 KB 1.00
Indexer_Moq 10 178,829.0 ns 1,061.58 ns 993.00 ns 72.66 0.59 1.7090 1.4648 29.89 KB 5.88
Indexer_NSubstitute 10 20,508.4 ns 42.58 ns 39.83 ns 8.33 0.05 1.5564 0.0305 25.58 KB 5.03
Indexer_FakeItEasy 10 21,034.2 ns 48.56 ns 43.05 ns 8.55 0.05 2.1667 0.0610 35.47 KB 6.97
Indexer_Imposter 10 2,055.5 ns 32.16 ns 30.09 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 7763 3.23GHz, 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 440.8 ns 4.29 ns 4.01 ns 1.00 0.01 0.1416 0.0010 2.32 KB 1.00
Method_Moq 1 182,246.8 ns 700.46 ns 620.94 ns 413.45 3.88 0.4883 - 14.58 KB 6.28
Method_NSubstitute 1 5,624.4 ns 23.03 ns 21.55 ns 12.76 0.12 0.5569 0.0076 9.12 KB 3.93
Method_FakeItEasy 1 6,029.7 ns 15.40 ns 13.65 ns 13.68 0.12 0.4959 - 8.11 KB 3.50
Method_Imposter 1 577.5 ns 22.97 ns 21.48 ns 1.31 0.05 0.2470 0.0029 4.04 KB 1.74
Method_TUnitMocks 1 722.9 ns 20.45 ns 19.13 ns 1.64 0.04 0.1774 0.0010 2.9 KB 1.25
Method_Mockolate 10 750.5 ns 13.95 ns 13.05 ns 1.00 0.02 0.1545 0.0010 2.53 KB 1.00
Method_Moq 10 186,777.6 ns 879.87 ns 779.99 ns 248.94 4.30 0.9766 0.7324 18.48 KB 7.30
Method_NSubstitute 10 8,346.8 ns 31.41 ns 27.84 ns 11.12 0.19 0.7324 0.0153 12.07 KB 4.77
Method_FakeItEasy 10 9,354.9 ns 111.64 ns 104.43 ns 12.47 0.25 0.9766 0.0305 16.05 KB 6.34
Method_Imposter 10 1,264.2 ns 16.17 ns 15.13 ns 1.68 0.03 0.3376 0.0057 5.52 KB 2.18
Method_TUnitMocks 10 1,763.7 ns 15.22 ns 14.23 ns 2.35 0.04 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 3.01GHz, 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 613.4 ns 9.14 ns 8.55 ns 1.00 0.02 0.1574 0.0010 2.58 KB 1.00
Property_Moq 1 11,911.9 ns 62.06 ns 48.45 ns 19.42 0.27 0.6104 - 10.39 KB 4.03
Property_NSubstitute 1 7,905.4 ns 41.34 ns 34.52 ns 12.89 0.18 0.6866 - 11.45 KB 4.44
Property_FakeItEasy 1 8,563.3 ns 163.76 ns 153.18 ns 13.96 0.31 0.6866 - 11.24 KB 4.36
Property_Imposter 1 460.0 ns 7.56 ns 6.70 ns 0.75 0.01 0.1912 0.0019 3.13 KB 1.21
Property_TUnitMocks 1 746.1 ns 11.30 ns 10.57 ns 1.22 0.02 0.1526 0.0010 2.51 KB 0.97
Property_Mockolate 10 1,093.9 ns 18.38 ns 17.19 ns 1.00 0.02 0.1869 - 3.07 KB 1.00
Property_Moq 10 18,547.0 ns 106.43 ns 99.56 ns 16.96 0.27 1.0986 - 18.28 KB 5.95
Property_NSubstitute 10 17,662.0 ns 177.62 ns 166.15 ns 16.15 0.29 1.2817 0.0305 21.08 KB 6.87
Property_FakeItEasy 10 20,628.2 ns 139.62 ns 130.60 ns 18.86 0.31 1.8616 - 30.81 KB 10.03
Property_Imposter 10 1,343.1 ns 11.58 ns 10.26 ns 1.23 0.02 0.2842 0.0019 4.67 KB 1.52
Property_TUnitMocks 10 2,311.6 ns 9.75 ns 8.65 ns 2.11 0.03 0.2823 - 4.66 KB 1.52
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
Callback_Mockolate 408.0 ns 3.78 ns 3.53 ns 1.00 0.01 0.1197 - 1.96 KB 1.00
Callback_Moq 96,263.3 ns 376.70 ns 333.93 ns 235.95 2.13 0.4883 0.2441 8.99 KB 4.59
Callback_NSubstitute 4,541.5 ns 16.83 ns 14.92 ns 11.13 0.10 0.4730 0.0076 7.74 KB 3.95
Callback_FakeItEasy 4,847.8 ns 24.30 ns 21.54 ns 11.88 0.11 0.4120 0.0153 6.81 KB 3.47
Callback_Imposter 414.7 ns 4.46 ns 3.72 ns 1.02 0.01 0.1454 0.0010 2.38 KB 1.22
Callback_TUnitMocks 599.5 ns 6.41 ns 5.68 ns 1.47 0.02 0.1602 0.0010 2.63 KB 1.34

@github-actions
Copy link
Copy Markdown

This is addressed in release v3.0.0.

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

1 participant