Skip to content

Comments

feat: add Register to property setup#339

Merged
vbreuss merged 2 commits intomainfrom
topic/add-property-register
Jan 2, 2026
Merged

feat: add Register to property setup#339
vbreuss merged 2 commits intomainfrom
topic/add-property-register

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Jan 2, 2026

This PR adds a Register() method to the property setup API, allowing properties to be registered without specifying a value. This is particularly useful when using MockBehavior.ThrowWhenNotSetup, as it enables properties to be marked as "setup" without defining specific behavior, preventing MockNotSetupException from being thrown when the property is accessed.

Key changes

  • Added Register() method to IPropertySetup<T> interface with XML documentation
  • Implemented Register() in PropertySetup<T> class (returns this for fluent chaining)
  • Added comprehensive tests validating both the exception scenario without registration and successful registration behavior

@vbreuss vbreuss self-assigned this Jan 2, 2026
@vbreuss vbreuss added the enhancement New feature or request label Jan 2, 2026
Copilot AI review requested due to automatic review settings January 2, 2026 18:46
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 Register() method to the property setup API, allowing properties to be registered without specifying a value. This is particularly useful when using MockBehavior.ThrowWhenNotSetup, as it enables properties to be marked as "setup" without defining specific behavior, preventing MockNotSetupException from being thrown when the property is accessed.

Key changes:

  • Added Register() method to IPropertySetup<T> interface with XML documentation
  • Implemented Register() in PropertySetup<T> class (returns this for fluent chaining)
  • Added comprehensive tests validating both the exception scenario without registration and successful registration behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Source/Mockolate/Setup/Interfaces.PropertySetup.cs Added Register() method signature to the property setup interface with XML documentation
Source/Mockolate/Setup/PropertySetup.cs Implemented the Register() method returning this for method chaining
Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.RegisterTests.cs Added test class with two tests validating registration behavior with ThrowingWhenNotSetup mode

@vbreuss vbreuss enabled auto-merge (squash) January 2, 2026 18:48
@github-actions
Copy link

github-actions bot commented Jan 2, 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.101
[Host] : .NET 10.0.1 (10.0.1, 10.0.125.57005), 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.407 μs 0.0058 μs 0.0054 μs 0.2232 - 3.66 KB
Simple_Moq 179.028 μs 0.4830 μs 0.4033 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.686 μs 0.0193 μs 0.0171 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.388 μs 0.0287 μs 0.0268 μs 0.4959 - 8.11 KB

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

Test Results

    14 files  ± 0      14 suites  ±0   4m 56s ⏱️ -3s
 1 794 tests + 2   1 793 ✅ + 2  1 💤 ±0  0 ❌ ±0 
11 987 runs  +14  11 986 ✅ +14  1 💤 ±0  0 ❌ ±0 

Results for commit 5a4448c. ± Comparison against base commit 7290839.

@vbreuss vbreuss merged commit b1c7ecf into main Jan 2, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-property-register branch January 2, 2026 18:54
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

This is addressed in release v0.48.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