-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to verify function calls with params keyword #539
Comments
Which means we end up with something like this: logger.DidNotReceive().Log(LogLevel.Error, 0, Arg.Any<FormattedLogValues>(), null, Arg.Any<Func<FormattedLogValues, Exception, string>>()); Rather than this, I'd suggest writing your own I also noticed Lastly, I recommend adding NSubstitute Analyzers to your test project to pick up any other surprising extension method instances. :) |
Thanks @dtchepak, I switched to TestLogger and it looks like a reasonable alternative to mocking The |
I thought the Glad to have helped. I'll close this issue, feel free to re-open it or a new issue if you have other questions. |
Question
I'm using ILogger from Microsoft.Extensions.Logging in my ASP.Net Core 2.2 code and I want to write a unit test where I can check if logger.LogError() was called or not.
In code it looks like:
SUT:
And I want to write such test code:
The problem is that the LogError() function has following signature (with params keyword):
public static void LogError(this ILogger logger, string message, params object[] args);
and when I run my test I'm getting an error:
So my question is: how can I check received calls for functions with an params argument?
The text was updated successfully, but these errors were encountered: