refactor: remove redundant check in ReturnMethodSetup#398
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes redundant null checks in the ReturnMethodSetup class that were checking if _returnCallbacks.Count == 0 before processing method invocations. These checks are unnecessary because the base class implementation already handles this scenario appropriately.
Changes:
- Removed redundant early-return checks for empty
_returnCallbacksfrom four overloadedGetReturnValuemethods - Added comprehensive test coverage to verify that the setup behavior works correctly both with and without explicit return values
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Source/Mockolate/Setup/ReturnMethodSetup.cs | Removed redundant _returnCallbacks.Count == 0 checks from four GetReturnValue method overloads |
| Tests/Mockolate.Tests/MockMethods/SetupMethodTests.ReturnsThrowsTests.cs | Added test cases SetupWithReturn_ShouldUseBaseValue and SetupWithReturn_ShouldIgnoreBaseValue for methods with 0-5 parameters to ensure proper behavior after removing the checks |
|
🚀 Benchmark ResultsDetails
|
|
This is addressed in release v1.0.3. |



This PR removes redundant null checks in the
ReturnMethodSetupclass that were checking if_returnCallbacks.Count == 0before processing method invocations. These checks are unnecessary because the base class implementation already handles this scenario appropriately.Key Changes:
_returnCallbacksfrom four overloadedGetReturnValuemethods