Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moq how to replace obsolete expression

Tags:

linq

moq

I'm using Moq in my code. I wrote an expression like:

mockInvoice.VerifySet(x => x.InvoiceAttachmentId, Times.Once());

Where InvoiceAttachmentId is a property on my Invoice.

It works fine but I get the warning:

Moq.MockExtensions.VerifySet(Moq.Mock, System.Linq.Expressions.Expression>, Moq.Times)' is obsolete: 'Replaced by VerifySet(Action, Times)'

Can anyone tell me how to rewrite it to satisfy the compiler and get rid of the warning? I'm unsure how to make the replacement to Action.

like image 520
AnonyMouse Avatar asked Jan 20 '12 02:01

AnonyMouse


1 Answers

mockInvoice.VerifySet(x => x.InvoiceAttachmentId = 123, Times.Once());

Replace 123 with the expected value.

If you want to permit any value, use:

mockInvoice.VerifySet(x => x.InvoiceAttachmentId = It.IsAny<int>(),
    Times.Once());
like image 77
TrueWill Avatar answered Oct 14 '22 04:10

TrueWill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!