Skip to content

feat: simplify constructor usage for MockMonitor<T>#442

Merged
vbreuss merged 2 commits intomainfrom
topic/add-mockmonitor-constructor
Jan 31, 2026
Merged

feat: simplify constructor usage for MockMonitor<T>#442
vbreuss merged 2 commits intomainfrom
topic/add-mockmonitor-constructor

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Jan 31, 2026

This PR replaces the constructor to MockMonitor<T> with a simpler one 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.

Key Changes:

  • Added a new public constructor MockMonitor(T mock) that internally handles the cast to IMockSubject<T>
  • Updated all test cases to use the simplified constructor syntax
  • Updated documentation examples to demonstrate the new simplified approach

@vbreuss vbreuss self-assigned this Jan 31, 2026
@vbreuss vbreuss added the enhancement New feature or request label Jan 31, 2026
Copilot AI review requested due to automatic review settings January 31, 2026 12:31
Copy link

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 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 to IMockSubject<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

@github-actions
Copy link

github-actions bot commented Jan 31, 2026

Test Results

    21 files  ±0      21 suites  ±0   4m 57s ⏱️ -21s
 2 518 tests +1   2 517 ✅ +1  1 💤 ±0  0 ❌ ±0 
16 807 runs  +7  16 806 ✅ +7  1 💤 ±0  0 ❌ ±0 

Results for commit c13464d. ± Comparison against base commit d2df665.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jan 31, 2026

🚀 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.531 μs 0.0044 μs 0.0037 μs 0.2270 - 3.73 KB
Simple_Moq 174.731 μs 1.1103 μs 0.9842 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.544 μs 0.0201 μs 0.0188 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.091 μs 0.0296 μs 0.0247 μs 0.4959 - 8.11 KB

@vbreuss vbreuss changed the title feat: add simpler constructor for MockMonitor<T> feat: simplify constructor usage for MockMonitor<T> Jan 31, 2026
@vbreuss vbreuss enabled auto-merge (squash) January 31, 2026 12:45
@sonarqubecloud
Copy link

@vbreuss vbreuss merged commit 5fb4b43 into main Jan 31, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-mockmonitor-constructor branch January 31, 2026 12:48
@github-actions
Copy link

This is addressed in release v1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments