Skip to content

Comments

refactor!: rename It.Is with predicate to It.Satisfies#308

Merged
vbreuss merged 2 commits intomainfrom
topic/rename-it.is-to-it.satisfies
Dec 13, 2025
Merged

refactor!: rename It.Is with predicate to It.Satisfies#308
vbreuss merged 2 commits intomainfrom
topic/rename-it.is-to-it.satisfies

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Dec 13, 2025

This PR refactors the parameter matching API by renaming It.Is<T>(predicate) to It.Satisfies<T>(predicate) and introduces a fluent API for custom equality comparers. The changes separate predicate-based matching from value-based equality matching, making the API more intuitive and consistent.

Key changes:

  • Renamed It.Is<T>(predicate) to It.Satisfies<T>(predicate) for predicate-based matching
  • Changed It.Is<T>(value, comparer) to It.Is<T>(value).Using(comparer) for custom equality comparers
  • Added .Using(comparer) fluent API to It.IsOneOf<T>(...) for consistency
  • Updated all test files and documentation to reflect the new API

Also move comparer to separate fluent callback and add it to `It.IsOneOf`
@vbreuss vbreuss self-assigned this Dec 13, 2025
Copilot AI review requested due to automatic review settings December 13, 2025 06:06
@vbreuss vbreuss added breaking change The changes require a new major version documentation Improvements or additions to documentation enhancement New feature or request labels Dec 13, 2025
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 refactors the parameter matching API by renaming It.Is<T>(predicate) to It.Satisfies<T>(predicate) and introduces a fluent API for custom equality comparers. The changes separate predicate-based matching from value-based equality matching, making the API more intuitive and consistent.

Key changes:

  • Renamed It.Is<T>(predicate) to It.Satisfies<T>(predicate) for predicate-based matching
  • Changed It.Is<T>(value, comparer) to It.Is<T>(value).Using(comparer) for custom equality comparers
  • Added .Using(comparer) fluent API to It.IsOneOf<T>(...) for consistency
  • Updated all test files and documentation to reflect the new API

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/Mockolate.Tests/MockMethods/VerifyInvokedTests.SpanTests.cs Updated verification calls to use It.Satisfies
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs Updated setup method to use It.Satisfies
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.SpanTests.cs Updated span-based setup methods to use It.Satisfies
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.OutRefParameterTests.cs Updated out/ref parameter test helpers to use It.Satisfies
Tests/Mockolate.Tests/MockMethods/SetupMethodTests.CallbackTests.cs Updated callback test setups to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/VerifySetIndexerTests.cs Updated indexer verification to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/VerifySetIndexerTests.SpanTests.cs Updated span-based indexer verification to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/VerifyGotIndexerTests.cs Updated indexer read verification to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/VerifyGotIndexerTests.SpanTests.cs Updated span-based indexer read verification to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.SpanTests.cs Updated span-based indexer setup to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnSetTests.cs Updated indexer setter callbacks to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnGetTests.cs Updated indexer getter callbacks to use It.Satisfies
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.InitializeWithTests.cs Updated indexer initialization to use It.Satisfies
Tests/Mockolate.Tests/MockBehaviorTests.InitializeTests.cs Updated behavior initialization to use It.Satisfies
Tests/Mockolate.Tests/MatchTests.AnyParametersTests.cs Fixed class name from ItTests to MatchTests
Tests/Mockolate.Tests/MatchExtensionsTests.cs Updated parameter monitor test to use It.Satisfies
Tests/Mockolate.Tests/ItTests.cs Updated core It tests to use It.Satisfies
Tests/Mockolate.Tests/ItTests.SatisfiesTests.cs New test file for It.Satisfies functionality
Tests/Mockolate.Tests/ItTests.IsTests.cs Removed predicate tests, updated comparer syntax to use .Using()
Tests/Mockolate.Tests/ItTests.IsOneOfTests.cs Updated to use It.Satisfies where appropriate
Tests/Mockolate.ExampleTests/ExampleTests.cs Updated example to use It.Satisfies
Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt Updated API surface to reflect new signatures
Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt Updated API surface to reflect new signatures
Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt Updated API surface to reflect new signatures
Source/Mockolate/It.Satisfies.cs New implementation of It.Satisfies method
Source/Mockolate/It.IsOneOf.cs Added .Using() fluent API for custom comparers
Source/Mockolate/It.Is.cs Removed predicate overload, changed comparer to fluent API
README.md Updated documentation to reflect API changes
Docs/pages/02-setup.md Updated documentation to reflect API changes

@vbreuss vbreuss changed the title refactor: rename It.Is with predicate to It.Satisfies refactor!: rename It.Is with predicate to It.Satisfies Dec 13, 2025
@github-actions
Copy link

github-actions bot commented Dec 13, 2025

Test Results

    14 files  ± 0      14 suites  ±0   5m 2s ⏱️ -14s
 1 658 tests + 2   1 657 ✅ + 2  1 💤 ±0  0 ❌ ±0 
11 095 runs  +14  11 094 ✅ +14  1 💤 ±0  0 ❌ ±0 

Results for commit 6344cf8. ± Comparison against base commit 4e06377.

This pull request removes 34 and adds 36 tests. Note that renamed tests count towards both.
Mockolate.Tests.ItTests+IsAnyParametersTests ‑ ShouldAlwaysMatch(values: ["", 1])
Mockolate.Tests.ItTests+IsAnyParametersTests ‑ ShouldAlwaysMatch(values: ["foo", null])
Mockolate.Tests.ItTests+IsAnyParametersTests ‑ ShouldAlwaysMatch(values: [null, null])
Mockolate.Tests.ItTests+IsAnyParametersTests ‑ ToString_ShouldReturnExpectedValue
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: -5, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: 1, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: 4, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: 42, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: 5, expectMatch: True)
Mockolate.Tests.ItTests+IsOneOfTests ‑ WithValue_ShouldMatchWhenEqualToAny(value: 6, expectMatch: True)
…
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: -5, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 1, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 4, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 42, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 5, expectMatch: True)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 6, expectMatch: True)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 7, expectMatch: True)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldMatchWhenEqualToAny(value: 8, expectMatch: False)
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldSupportCovarianceInSetup
Mockolate.Tests.ItTests+IsOneOfTests ‑ ShouldSupportCovarianceInVerify
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 13, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz, 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-v4

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.498 μs 0.0097 μs 0.0090 μs 0.1488 - 3.66 KB
Simple_Moq 134.435 μs 1.2666 μs 0.9889 μs 0.4883 0.2441 14.56 KB
Simple_NSubstitute 5.973 μs 0.0304 μs 0.0269 μs 0.3662 - 9.14 KB
Simple_FakeItEasy 5.905 μs 0.0511 μs 0.0478 μs 0.3281 - 8.12 KB

@vbreuss vbreuss enabled auto-merge (squash) December 13, 2025 06:13
@sonarqubecloud
Copy link

@vbreuss vbreuss merged commit fbc8a6b into main Dec 13, 2025
12 checks passed
@vbreuss vbreuss deleted the topic/rename-it.is-to-it.satisfies branch December 13, 2025 06:17
@github-actions
Copy link

This is addressed in release v0.44.0.

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

Labels

breaking change The changes require a new major version documentation Improvements or additions to documentation 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