Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the AAA syntax to do an AssertWasCalled but ignore arguments

I'm using the new AAA syntax and wanted to know the syntax to do the below and have the mock ignore the arguments:

mockAccount.AssertWasCalled(account => account.SetPassword("dsfdslkj"));

I think the below is how I would do this with the record/ replay model but I wanted to see if this could be done with AAA using 3.6:

mockAccount.Expect(account => account.SetPassword("sdfdsf")).IgnoreArguments();
mockAccount.VerifyAllExpectations();
like image 792
Toran Billups Avatar asked Mar 16 '10 16:03

Toran Billups


2 Answers

To ignore the arguments, use Arg<string>.Is.Anything:

mockAccount.AssertWasCalled(acc => acc.SetPassword(Arg<string>.Is.Anything));
like image 137
Judah Gabriel Himango Avatar answered Nov 12 '22 19:11

Judah Gabriel Himango


Found it with the obvious google search - hope someone else finds this of value

mockAccount.AssertWasNotCalled(x => x.SetPassword(""), y => y.IgnoreArguments());
like image 11
Toran Billups Avatar answered Nov 12 '22 20:11

Toran Billups