Skip to content

fix: combine initialize and return for properties#397

Merged
vbreuss merged 2 commits into
mainfrom
topic/fix-combine-initialize-and-return
Jan 24, 2026
Merged

fix: combine initialize and return for properties#397
vbreuss merged 2 commits into
mainfrom
topic/fix-combine-initialize-and-return

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jan 24, 2026

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.

Key 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 InitializeWith and Returns methods

@vbreuss vbreuss self-assigned this Jan 24, 2026
Copilot AI review requested due to automatic review settings January 24, 2026 19:35
@vbreuss vbreuss added the bug Something isn't working label Jan 24, 2026
Copy link
Copy Markdown

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 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 InitializeWith and Returns methods

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

Comment thread Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.cs
Comment thread Source/Mockolate/Setup/PropertySetup.cs
@vbreuss vbreuss enabled auto-merge (squash) January 24, 2026 19:37
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 24, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 3.16GHz, 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.612 μs 0.0140 μs 0.0131 μs 0.2270 - 3.73 KB
Simple_Moq 183.051 μs 1.4197 μs 1.2585 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.672 μs 0.0298 μs 0.0265 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.340 μs 0.0622 μs 0.0582 μs 0.4959 - 8.11 KB

@github-actions
Copy link
Copy Markdown

Test Results

    21 files  ± 0      21 suites  ±0   5m 59s ⏱️ -13s
 2 368 tests + 3   2 367 ✅ + 3  1 💤 ±0  0 ❌ ±0 
15 881 runs  +21  15 880 ✅ +21  1 💤 ±0  0 ❌ ±0 

Results for commit 6674f43. ± Comparison against base commit 84a5c72.

@vbreuss vbreuss merged commit 5dab55b into main Jan 24, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/fix-combine-initialize-and-return branch January 24, 2026 19:42
@github-actions
Copy link
Copy Markdown

This is addressed in release v1.0.3.

@github-actions github-actions Bot added the state: released The issue is released label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants