feat: simplify constructor usage for MockMonitor<T>#442
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a simpler constructor to MockMonitor<T> that accepts the mock instance directly (type T) instead of requiring users to cast to IMockSubject<T> and access the Mock property. This change streamlines the API and improves usability.
Changes:
- Added a new public constructor
MockMonitor(T mock)that internally handles the cast toIMockSubject<T> - Updated all test cases to use the simplified constructor syntax
- Updated documentation examples to demonstrate the new simplified approach
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Mockolate/Monitor/MockMonitor.cs | Implements the new constructor that accepts T directly and delegates to a private constructor handling the cast |
| Tests/Mockolate.Tests/Monitor/MockMonitorTests.cs | Simplifies all test setup code by using the new constructor instead of manual casting |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt | Updates API baseline to include the new constructor signature |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt | Updates API baseline to include the new constructor signature |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt | Updates API baseline to include the new constructor signature |
| README.md | Updates documentation examples to show the new simplified constructor usage and adds alternative MonitorMock() extension method example |
| Docs/pages/advanced-features/03-monitor-interactions.md | Updates documentation to demonstrate the new constructor and adds alternative MonitorMock() extension method example |
🚀 Benchmark ResultsDetails
|
MockMonitor<T>MockMonitor<T>
|
|
This is addressed in release v1.1.0. |



This PR replaces the constructor to
MockMonitor<T>with a simpler one that accepts the mock instance directly (typeT) instead of requiring users to cast toIMockSubject<T>and access theMockproperty. This change streamlines the API and improves usability.Key Changes:
MockMonitor(T mock)that internally handles the cast toIMockSubject<T>