You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Delegates with a params parameter have no per-element matcher overload #1045
Sources.MockDelegate.cs never emits the per-element overload. For params object[] the only applicable delegate overload is (IParameter<int>?, params object[]), so element matchers are captured as array elements and compared as values:
publicinterfaceILog{intInvoke(intlevel,paramsobject[]args);}publicdelegateintLogger(intlevel,paramsobject[]args);// method: the setup returns its value, the verification passeslog.Mock.Setup.Invoke(It.Is(4),It.IsAny<object>(),It.Is<object>(2)).Returns(1);// delegate: compiles, never matcheslogger.Mock.Setup(It.Is(4),It.IsAny<object>(),It.Is<object>(2)).Returns(1);logger.Mock.Verify(It.Is(4),It.IsAny<object>(),It.Is<object>(2)).Once();// Expected that mock invoked method Invoke(4, System.Object[]) exactly once, but it never did.
Every other shape behaves the same on delegates and methods (pinned by ParamsObjectArray_InClassicMode_OnDelegates_ShouldBindLikeMethods and the union variant in Tests/Mockolate.SourceGenerators.Tests/ParamsObjectArrayTests.cs on that branch): whole-array matcher, literal elements, null, a single params parameter, Match.AnyParameters(). That test leaves this shape out.
Check first: what the same call does for params int[] / params string[] on a delegate (expected: a compile error, since a matcher is not an element), and for a delegate whose only parameter is params.
Activity
fix: match params arrays element by element on delegate mocks