Skip to content

coverage: add tests and accessor for property setup snapshot in MockRegistry#732

Merged
vbreuss merged 1 commit into
mainfrom
topic/add-tests-and-accessor-for-property-setup-snapshot-in-MockRegistry
Apr 30, 2026
Merged

coverage: add tests and accessor for property setup snapshot in MockRegistry#732
vbreuss merged 1 commit into
mainfrom
topic/add-tests-and-accessor-for-property-setup-snapshot-in-MockRegistry

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Apr 30, 2026

This pull request introduces improvements to the handling and testing of property setup snapshots in the MockRegistry class. The main changes include adding a new internal accessor for property setup snapshots, enhancing test coverage for property setup behaviors, and adding comments to clarify code paths for mutation testing tools.

Property setup snapshot improvements

  • Added a new internal method GetPropertySetupSnapshot(int memberId) to MockRegistry.Interactions.cs for retrieving the current property setup snapshot by member ID. This method is intended for diagnostics and direct verification in tests.

Test coverage enhancements

  • Added multiple new unit tests in MockRegistrySetupSnapshotTests.cs to verify correct behavior of property setup snapshotting, including:
    • Ensuring earlier entries are preserved when resizing the property setup table.
    • Verifying that default setups overwrite previous defaults, but user setups are retained over defaults.
    • Confirming that setups are correctly published to the snapshot table for both direct and scenario-based registrations.

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

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ± 0      21 suites  ±0   12m 7s ⏱️ + 1m 4s
 3 933 tests + 5   3 931 ✅ + 5  2 💤 ±0  0 ❌ ±0 
25 549 runs  +35  25 545 ✅ +35  4 💤 ±0  0 ❌ ±0 

Results for commit c9ae6d2. ± Comparison against base commit 18e6beb.

@vbreuss vbreuss merged commit 11710b5 into main Apr 30, 2026
16 checks passed
@vbreuss vbreuss deleted the topic/add-tests-and-accessor-for-property-setup-snapshot-in-MockRegistry branch April 30, 2026 19:18
@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.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 Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Event_Mockolate 359.6 ns 7.55 ns 7.06 ns 1.00 0.03 0.1254 0.0005 2.05 KB 1.00
Event_Moq 16,092.6 ns 23.75 ns 19.83 ns 44.76 0.85 0.7324 - 12.51 KB 6.09
Event_NSubstitute 5,734.5 ns 42.94 ns 40.17 ns 15.95 0.32 0.5493 0.0076 9.05 KB 4.40
Event_FakeItEasy 211,865.7 ns 1,042.58 ns 975.23 ns 589.32 11.43 0.7324 0.4883 15.39 KB 7.49
Event_Imposter 1,454.0 ns 25.45 ns 23.81 ns 4.04 0.10 0.5379 0.0153 8.8 KB 4.29
Event_TUnitMocks 208.0 ns 5.72 ns 5.35 ns 0.58 0.02 0.0837 0.0002 1.37 KB 0.67
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
Indexer_Mockolate 1 922.0 ns 3.85 ns 3.22 ns 1.00 0.00 0.2460 0.0019 4.03 KB 1.00
Indexer_Moq 1 216,790.5 ns 1,625.65 ns 1,520.64 ns 235.14 1.78 0.9766 0.4883 20.37 KB 5.05
Indexer_NSubstitute 1 9,435.6 ns 101.95 ns 95.36 ns 10.23 0.11 0.7782 - 12.78 KB 3.17
Indexer_FakeItEasy 1 12,096.7 ns 83.03 ns 77.67 ns 13.12 0.09 0.8392 0.0305 13.88 KB 3.44
Indexer_Imposter 1 1,038.1 ns 39.89 ns 37.31 ns 1.13 0.04 0.3147 0.0038 5.16 KB 1.28
Indexer_Mockolate 10 2,602.6 ns 49.25 ns 46.07 ns 1.00 0.02 0.3090 - 5.09 KB 1.00
Indexer_Moq 10 230,846.3 ns 2,306.71 ns 2,157.70 ns 88.72 1.71 1.7090 1.4648 29.89 KB 5.88
Indexer_NSubstitute 10 22,656.2 ns 374.16 ns 349.99 ns 8.71 0.20 1.5564 0.0305 25.58 KB 5.03
Indexer_FakeItEasy 10 24,703.0 ns 480.40 ns 449.37 ns 9.49 0.23 2.1667 0.0610 35.47 KB 6.97
Indexer_Imposter 10 2,256.1 ns 52.48 ns 49.09 ns 0.87 0.02 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 454.2 ns 5.48 ns 5.12 ns 1.00 0.02 0.1416 0.0010 2.32 KB 1.00
Method_Moq 1 128,539.1 ns 570.34 ns 505.59 ns 283.03 3.30 0.4883 - 14.58 KB 6.28
Method_NSubstitute 1 5,226.4 ns 28.75 ns 26.90 ns 11.51 0.14 0.5569 0.0076 9.12 KB 3.93
Method_FakeItEasy 1 5,436.4 ns 56.95 ns 53.27 ns 11.97 0.17 0.4959 - 8.11 KB 3.50
Method_Imposter 1 540.3 ns 2.04 ns 1.70 ns 1.19 0.01 0.2470 0.0029 4.04 KB 1.74
Method_TUnitMocks 1 694.1 ns 6.85 ns 6.41 ns 1.53 0.02 0.1774 0.0010 2.9 KB 1.25
Method_Mockolate 10 723.2 ns 10.80 ns 10.10 ns 1.00 0.02 0.1545 0.0010 2.53 KB 1.00
Method_Moq 10 133,326.1 ns 472.34 ns 418.72 ns 184.39 2.53 0.9766 0.7324 18.48 KB 7.30
Method_NSubstitute 10 7,725.0 ns 28.17 ns 23.52 ns 10.68 0.15 0.7324 0.0153 12.07 KB 4.77
Method_FakeItEasy 10 8,430.6 ns 61.84 ns 57.84 ns 11.66 0.17 0.9766 0.0305 16.05 KB 6.34
Method_Imposter 10 1,128.9 ns 5.03 ns 4.46 ns 1.56 0.02 0.3376 0.0057 5.52 KB 2.18
Method_TUnitMocks 10 1,765.5 ns 17.35 ns 16.23 ns 2.44 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 2.71GHz, 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 544.2 ns 8.34 ns 7.39 ns 1.00 0.02 0.1574 0.0010 2.58 KB 1.00
Property_Moq 1 12,383.2 ns 90.37 ns 75.46 ns 22.76 0.33 0.6104 - 10.39 KB 4.03
Property_NSubstitute 1 7,770.1 ns 53.17 ns 47.13 ns 14.28 0.20 0.6866 - 11.45 KB 4.44
Property_FakeItEasy 1 8,655.7 ns 150.34 ns 140.63 ns 15.91 0.33 0.6866 - 11.24 KB 4.36
Property_Imposter 1 458.2 ns 7.02 ns 6.22 ns 0.84 0.02 0.1912 0.0019 3.13 KB 1.21
Property_TUnitMocks 1 780.5 ns 19.41 ns 18.15 ns 1.43 0.04 0.1526 0.0010 2.51 KB 0.97
Property_Mockolate 10 1,095.7 ns 15.12 ns 13.41 ns 1.00 0.02 0.1869 - 3.07 KB 1.00
Property_Moq 10 19,354.9 ns 75.99 ns 67.37 ns 17.67 0.22 1.0986 - 18.28 KB 5.95
Property_NSubstitute 10 17,433.6 ns 208.09 ns 194.64 ns 15.91 0.26 1.2817 0.0305 21.08 KB 6.87
Property_FakeItEasy 10 20,176.0 ns 211.80 ns 198.12 ns 18.42 0.28 1.8616 - 30.81 KB 10.03
Property_Imposter 10 1,192.3 ns 13.03 ns 10.88 ns 1.09 0.02 0.2842 0.0019 4.67 KB 1.52
Property_TUnitMocks 10 2,149.5 ns 11.80 ns 9.21 ns 1.96 0.02 0.2823 - 4.66 KB 1.52
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 Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
Callback_Mockolate 388.6 ns 3.25 ns 3.04 ns 1.00 0.01 0.1197 - 1.96 KB 1.00
Callback_Moq 96,345.3 ns 333.15 ns 295.33 ns 247.97 2.01 0.4883 0.2441 8.88 KB 4.53
Callback_NSubstitute 4,377.2 ns 22.44 ns 20.99 ns 11.27 0.10 0.4730 0.0076 7.74 KB 3.95
Callback_FakeItEasy 4,875.2 ns 23.82 ns 21.12 ns 12.55 0.11 0.4120 0.0153 6.81 KB 3.47
Callback_Imposter 414.8 ns 7.71 ns 7.21 ns 1.07 0.02 0.1454 0.0010 2.38 KB 1.22
Callback_TUnitMocks 587.1 ns 4.80 ns 4.49 ns 1.51 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.

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