Skip to content

coverage: add missing tests for Callback#401

Merged
vbreuss merged 1 commit into
mainfrom
topic/improve-callback-coverage
Jan 24, 2026
Merged

coverage: add missing tests for Callback#401
vbreuss merged 1 commit into
mainfrom
topic/improve-callback-coverage

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jan 24, 2026

This PR adds test coverage for the Callback class's For and When methods, particularly testing how they work together to limit the number of matching invocations. The changes include tests for both void and return methods, with and without InParallel, and new low-level unit tests for the Callback class itself.

Key Changes:

  • Added tests for For method behavior when combined with When conditions in return method setups
  • Added tests for For method behavior when combined with When conditions in void method setups and callbacks
  • Created a new test file with direct unit tests for the Callback class

@vbreuss vbreuss self-assigned this Jan 24, 2026
Copilot AI review requested due to automatic review settings January 24, 2026 22:08
@vbreuss vbreuss added the coverage Additional tests for edge cases or improvement of test coverage label Jan 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds test coverage for the Callback class's For and When methods, particularly testing how they work together to limit the number of matching invocations. The changes include tests for both void and return methods, with and without InParallel, and new low-level unit tests for the Callback class itself.

Changes:

  • Added tests for For method behavior when combined with When conditions in return method setups
  • Added tests for For method behavior when combined with When conditions in void method setups and callbacks
  • Created a new test file with direct unit tests for the Callback class
  • Removed an unnecessary blank line from the Callback class implementation

Reviewed changes

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

File Description
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.ReturnsThrowsTests.cs Added tests for For method limiting matches on return and void method setups
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs Added tests for For method limiting matches on callbacks with and without InParallel
Tests/Mockolate.Internal.Tests/CallbackTests.cs New file with direct unit tests for the Callback class's Invoke methods with For and When
Source/Mockolate/Setup/Callback.cs Removed unnecessary blank line

Comment thread Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs
Comment thread Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs
Comment thread Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs
Comment thread Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs
Comment thread Tests/Mockolate.Internal.Tests/CallbackTests.cs
Comment thread Tests/Mockolate.Internal.Tests/CallbackTests.cs
@vbreuss vbreuss enabled auto-merge (squash) January 24, 2026 22:12
@vbreuss vbreuss disabled auto-merge January 24, 2026 22:12
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss enabled auto-merge (squash) January 24, 2026 22:12
@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ±  0      21 suites  ±0   6m 6s ⏱️ +33s
 2 397 tests + 18   2 396 ✅ + 18  1 💤 ±0  0 ❌ ±0 
16 072 runs  +126  16 071 ✅ +126  1 💤 ±0  0 ❌ ±0 

Results for commit f756af9. ± Comparison against base commit 6ae56f2.

@vbreuss vbreuss merged commit e8b8d93 into main Jan 24, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/improve-callback-coverage branch January 24, 2026 22:13
@github-actions
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.517 μs 0.0107 μs 0.0095 μs 0.2270 - 3.73 KB
Simple_Moq 179.803 μs 0.6038 μs 0.5042 μs 0.4883 - 14.77 KB
Simple_NSubstitute 5.642 μs 0.0191 μs 0.0179 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.225 μs 0.0213 μs 0.0189 μs 0.4959 - 8.11 KB

@github-actions
Copy link
Copy Markdown

This is addressed in release v1.0.3.

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