fix: For does not repeat correctly#450
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the behavior of the For modifier in the Mockolate library to properly repeat callback patterns instead of limiting usage. Previously, For would limit callbacks to execute only once for the specified number of times. Now, For repeats the entire callback pattern indefinitely.
Changes:
- Modified
Forbehavior to repeat patterns instead of limiting them to one-time execution - Renamed
Fortests toReturns_For_ShouldRepeatUsage_ForTheSpecifiedNumberto reflect new behavior - Moved old
Fortests toOnly(which maintains the original limiting behavior) - Updated documentation to show the new repeating pattern behavior
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Mockolate/Setup/Callback.cs | Core implementation changes to enable pattern repetition via iteration counter |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.ReturnsThrowsTests.cs | Updated property tests to reflect new For behavior and added Only tests |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.OnSetTests.cs | Renamed For tests to Only tests for property setters |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.OnGetTests.cs | Renamed For tests to Only tests for property getters |
| Tests/Mockolate.Tests/MockMethods/SetupMethodTests.ReturnsThrowsTests.cs | Updated method tests to reflect new For behavior and added Only tests |
| Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs | Renamed For tests to Only tests for method callbacks |
| Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.ReturnsThrowsTests.cs | Updated indexer tests to reflect new For behavior and added Only tests |
| Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnSetTests.cs | Renamed For tests to Only tests for indexer setters |
| Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnGetTests.cs | Renamed For tests to Only tests for indexer getters |
| Docs/pages/advanced-features/02-advanced-callback-features.md | Updated documentation to show new repeating pattern behavior |
Test Results 21 files ± 0 21 suites ±0 5m 12s ⏱️ - 1m 12s Results for commit db75dee. ± Comparison against base commit 466708f. This pull request removes 102 and adds 92 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
|
|
|
This is addressed in release v1.2.0. |



This PR fixes the behavior of the
Formodifier in the Mockolate library to properly repeat callback patterns instead of limiting usage. Previously,Forwould limit callbacks to execute only once for the specified number of times. Now,Forrepeats the entire callback pattern indefinitely.Key Changes:
Forbehavior to repeat patterns instead of limiting them to one-time executionFortests toReturns_For_ShouldRepeatUsage_ForTheSpecifiedNumberto reflect new behaviorFortests toOnly(which maintains the original limiting behavior)