feat: add per-element matchers and values for params array parameters#796
Conversation
1718e8e to
4b8a1d0
Compare
Test Results 24 files ± 0 24 suites ±0 10m 3s ⏱️ -10s Results for commit 0d79513. ± Comparison against base commit 4c019e4. This pull request removes 1 and adds 18 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
Details
Details
Details
Details
Details
|
Generate two additional Setup/Verify overloads for methods ending in a params T[] parameter: one accepting params IParameter<T>[] for per-element matchers (e.g. Setup.M(It.IsAny<int>(), It.IsAny<bool>(), It.IsFalse())) and one accepting params T[] for per-element values matched element-wise by value (e.g. Setup.M(It.IsAny<int>(), true, false)). The matcher overload wraps the elements in a new ParamsArrayParameterMatch<T> composite; the value overload routes through It.SequenceEquals so the whole array is compared element-wise rather than by reference. This replaces the previous whole-array literal value overload for the params parameter, so an explicitly passed array argument is now matched by value equality instead of reference equality. Overload resolution between the matcher and value params overloads for the zero-element case is handled by the existing OverloadResolutionPriority mechanism.
4b8a1d0 to
8694ee0
Compare
…hers Guard the typed IParameterMatch<T[]> dispatch of It.SequenceEquals and It.Contains against a null collection value, so a recorded null params array yields a non-match instead of a NullReferenceException. Previously only the non-generic IParameter.Matches(object?) path was null-safe. Also guard ParamsArrayParameterMatch against null per-element matchers in both Matches and InvokeCallbacks, and add direct unit tests covering the match/callback/ToString branches.
8694ee0 to
0d79513
Compare
|
…es for params array parameters (#796) by Valentin Breuß
…es for params array parameters (#796) by Valentin Breuß
|
This is addressed in release v3.3.0. |



Generate two additional Setup/Verify overloads for methods ending in a params T[] parameter: one accepting params IParameter[] for per-element matchers (e.g. Setup.M(It.IsAny(), It.IsAny(), It.IsFalse())) and one accepting params T[] for per-element values matched element-wise by value (e.g. Setup.M(It.IsAny(), true, false)). The matcher overload wraps the elements in a new ParamsArrayParameterMatch composite; the value overload routes through It.SequenceEquals so the whole array is compared element-wise rather than by reference.
This replaces the previous whole-array literal value overload for the params parameter, so an explicitly passed array argument is now matched by value equality instead of reference equality. Overload resolution between the matcher and value params overloads for the zero-element case is handled by the existing OverloadResolutionPriority mechanism.