code4it-dev / blog-comments

https://www.code4it.dev/
1 stars 0 forks source link

blog/check-objects-called-mocks-in-moq/ #65

Open utterances-bot opened 9 months ago

utterances-bot commented 9 months ago

3 ways to check the object passed to mocks with Moq in C# | Code4IT

Code4IT - a blog for .NET enthusiasts, Azure lovers, and Backend developers

https://www.code4it.dev/blog/check-objects-called-mocks-in-moq/

m-szulc commented 9 months ago

You can use Capture:

List users = new(); userRepo.Setup( => .Capture.In(users)); actual = users.SingleOrDefault();

bellons91 commented 9 months ago

I can't find that method. Does it come from Moq?

IanIsFluent commented 7 months ago

This is really useful, thanks.

I especially liked the idea of asserting in the verify, then just returning true if it makes it through.