fix: combine initialize and return for properties#397
Conversation
There was a problem hiding this comment.
Pull request overview
This PR combines the InitializeWith and Returns methods for property setups, enabling properties to have an initialized value that can be used as input to return callbacks. This allows callbacks to operate on the current property value, which is particularly useful with conditional returns using When predicates.
Changes:
- Combined initialization and return value functionality for properties
- Properties now maintain initialized state to prevent unnecessary reinitialization
- Added test coverage for the interaction between
InitializeWithandReturnsmethods
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Mockolate/Setup/PropertySetup.cs | Added check to prevent reinitialization when return callbacks exist |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.cs | Added test for type mismatch in InitializeValue and helper method |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.InitializeWithTests.cs | Reorganized tests alphabetically and added new test for InitializeWith + Returns combination |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.ReturnsThrowsTests.cs | Reorganized tests and added coverage for InitializeWith + Returns interaction scenarios |
| Tests/Mockolate.Tests/SetupExtensionsTests.cs | Added property initialization to tests for proper state management |
|
🚀 Benchmark ResultsDetails
|
|
This is addressed in release v1.0.3. |



This PR combines the
InitializeWithandReturnsmethods for property setups, enabling properties to have an initialized value that can be used as input to return callbacks. This allows callbacks to operate on the current property value, which is particularly useful with conditional returns usingWhenpredicates.Key Changes:
InitializeWithandReturnsmethods