Skip to content

Comments

feat: add IsOneOf<T>#299

Merged
vbreuss merged 1 commit intomainfrom
topic/add-isoneof
Dec 11, 2025
Merged

feat: add IsOneOf<T>#299
vbreuss merged 1 commit intomainfrom
topic/add-isoneof

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Dec 11, 2025

This PR adds a new IsOneOf<T> parameter matcher to the Mockolate library that allows matching parameters against a collection of possible values. Additionally, it refactors the test class naming convention from MatchTests to ItTests to better align with the It class being tested.

Key changes:

  • Implements It.IsOneOf<T>() method for matching parameters against multiple values
  • Renames test class from MatchTests to ItTests across all test files

@vbreuss vbreuss self-assigned this Dec 11, 2025
Copilot AI review requested due to automatic review settings December 11, 2025 20:05
@vbreuss vbreuss added the enhancement New feature or request label Dec 11, 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 adds a new IsOneOf<T> parameter matcher to the Mockolate library that allows matching parameters against a collection of possible values. Additionally, it refactors the test class naming convention from MatchTests to ItTests to better align with the It class being tested.

Key changes:

  • Implements It.IsOneOf<T>() method for matching parameters against multiple values
  • Renames test class from MatchTests to ItTests across all test files
  • Reorganizes tests by moving null-matching tests to a dedicated IsNullTests class

Reviewed changes

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

Show a summary per file
File Description
Source/Mockolate/It.IsOneOf.cs Implements the new IsOneOf<T> method with internal ParameterIsOneOfMatch<T> class
Tests/Mockolate.Tests/ItTests.IsOneOfTests.cs Adds comprehensive test coverage for IsOneOf<T> including covariance support
Tests/Mockolate.Tests/ItTests.cs Renames parent test class from MatchTests to ItTests
Tests/Mockolate.Tests/ItTests.*.cs Updates all nested test classes to use ItTests parent and consistent Is*Tests naming
Tests/Mockolate.Tests/ItTests.IsNullTests.cs Moves nullable value matching test from IsTests to IsNullTests
Tests/Mockolate.Api.Tests/Expected/Mockolate_*.txt Updates API surface expectations for all target frameworks

@vbreuss vbreuss enabled auto-merge (squash) December 11, 2025 20:07
@sonarqubecloud
Copy link

@github-actions
Copy link

Test Results

    14 files  ± 0      14 suites  ±0   4m 51s ⏱️ +17s
 1 546 tests +12   1 545 ✅ +12  1 💤 ±0  0 ❌ ±0 
10 311 runs  +84  10 310 ✅ +84  1 💤 ±0  0 ❌ ±0 

Results for commit 4586c0b. ± Comparison against base commit 4424f6f.

This pull request removes 114 and adds 126 tests. Note that renamed tests count towards both.
Mockolate.Tests.MatchTests ‑ InvokeCallbacks_WithCorrectType_ShouldInvokeCallback
Mockolate.Tests.MatchTests ‑ InvokeCallbacks_WithDifferentType_ShouldNotInvokeCallback
Mockolate.Tests.MatchTests ‑ InvokeCallbacks_WithNull_WhenTypeIsNotNullable_ShouldNotInvokeCallback
Mockolate.Tests.MatchTests ‑ InvokeCallbacks_WithNull_WhenTypeIsNullable_ShouldInvokeCallback
Mockolate.Tests.MatchTests ‑ ShouldOnlyHaveOneParameterlessPrivateConstructor
Mockolate.Tests.MatchTests ‑ ToString_NamedParameter_ShouldReturnExpectedValue
Mockolate.Tests.MatchTests+AnyOutTests ‑ ShouldCheckType(value: "foo", expectMatch: False)
Mockolate.Tests.MatchTests+AnyOutTests ‑ ShouldCheckType(value: 123, expectMatch: True)
Mockolate.Tests.MatchTests+AnyOutTests ‑ ShouldCheckType(value: 42, expectMatch: False)
Mockolate.Tests.MatchTests+AnyOutTests ‑ ShouldCheckType(value: null, expectMatch: True)
…
Mockolate.Tests.ItTests ‑ InvokeCallbacks_WithCorrectType_ShouldInvokeCallback
Mockolate.Tests.ItTests ‑ InvokeCallbacks_WithDifferentType_ShouldNotInvokeCallback
Mockolate.Tests.ItTests ‑ InvokeCallbacks_WithNull_WhenTypeIsNotNullable_ShouldNotInvokeCallback
Mockolate.Tests.ItTests ‑ InvokeCallbacks_WithNull_WhenTypeIsNullable_ShouldInvokeCallback
Mockolate.Tests.ItTests ‑ ShouldOnlyHaveOneParameterlessPrivateConstructor
Mockolate.Tests.ItTests ‑ ToString_NamedParameter_ShouldReturnExpectedValue
Mockolate.Tests.ItTests+IsAnyOutTests ‑ ShouldCheckType(value: "foo", expectMatch: False)
Mockolate.Tests.ItTests+IsAnyOutTests ‑ ShouldCheckType(value: 123, expectMatch: True)
Mockolate.Tests.ItTests+IsAnyOutTests ‑ ShouldCheckType(value: 42, expectMatch: False)
Mockolate.Tests.ItTests+IsAnyOutTests ‑ ShouldCheckType(value: null, expectMatch: True)
…

@vbreuss vbreuss merged commit 2d7c17a into main Dec 11, 2025
12 checks passed
@vbreuss vbreuss deleted the topic/add-isoneof branch December 11, 2025 20:10
@github-actions
Copy link

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.59GHz, 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.478 μs 0.0105 μs 0.0098 μs 0.2232 - 3.66 KB
Simple_Moq 175.058 μs 0.8663 μs 0.7680 μs 0.4883 - 14.77 KB
Simple_NSubstitute 5.673 μs 0.0258 μs 0.0241 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.231 μs 0.0271 μs 0.0241 μs 0.4959 - 8.11 KB

@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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add It.IsOneOf(params T[])

1 participant