Skip to content
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

Does not replace the 'Callback' method from Moq #3

Open
Creastoff opened this issue Aug 11, 2023 · 1 comment
Open

Does not replace the 'Callback' method from Moq #3

Creastoff opened this issue Aug 11, 2023 · 1 comment

Comments

@Creastoff
Copy link

For the given code snippet, there is no support to replace the '.Callback' method with the NSubstitute equivalent.
_mockAuditLog .Setup(l => l.Add(AuditLevel.Information, It.IsAny(), null, It.IsAny(), It.IsAny<object[]>())) .Callback<AuditLevel, AuditAction, Exception, string, object[]>((l, a, ex, msg, args) => { _action = a; Message = msg; _args = args; });

@yor-so
Copy link

yor-so commented Aug 22, 2023

Also, this should cover exceptions:

I'm not sure if this issue should also cover exceptions, since they use callbacks for void methods:
https://nsubstitute.github.io/help/throwing-exceptions/

moq:
mock(x => x.Method(It.IsAny())).Throws();

NSubstitute:
mock.When(x => x.Method(Arg.Any())).Do(call => { throw new Exception(); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants