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 4 months ago

utterances-bot commented 4 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 4 months ago

You can use Capture:

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

bellons91 commented 4 months ago

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

IanIsFluent commented 2 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.

IanGrainger commented 2 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.

IanIsFluent commented 2 months ago

Oops - I meant to comment with my personal GitHub account - can you remove this one? (I sent a comment from both).

On Fri, Apr 12, 2024 at 12:48 PM IanGrainger @.***> wrote:

This is really useful, thanks.

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

— Reply to this email directly, view it on GitHub https://github.com/code4it-dev/blog-comments/issues/65#issuecomment-2051606690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIELT6DIFFNRAUCX3IDQKQ3Y47CYTAVCNFSM6AAAAABDBYXC46VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJRGYYDMNRZGA . You are receiving this because you commented.Message ID: @.***>

--

Ian Grainger (he/him) Principal Engineer

this.isfluent.com http://this.isfluent.com/

--

Fluent (Cambridge) Ltd is a limited company registered in England and Wales No. 6159670. Registered office 7 Pioneer Court https://this.isfluent.com/contact, Vision Park, Histon, Cambridge. CB24 9PT