13

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();
Oleks
  • 31,955
  • 11
  • 77
  • 132
Toran Billups
  • 27,111
  • 40
  • 155
  • 268

2 Answers2

16

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

mockAccount.AssertWasCalled(acc => acc.SetPassword(Arg<string>.Is.Anything));
Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
11

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

mockAccount.AssertWasNotCalled(x => x.SetPassword(""), y => y.IgnoreArguments());
Ralph Willgoss
  • 11,750
  • 4
  • 64
  • 67
Toran Billups
  • 27,111
  • 40
  • 155
  • 268