So, I have a method with this signature:
IList<Mail> FindFilteredPaged(
QueryFilter filter,
int pageIndex,
int pageSize,
out int totalRecords);
and I wanna setup expectation so I can check that the filter parameter is null. The problem comes with the final out paremter. My current expectation setup is like this:
Expect
.Call(registryMailService.FindFilteredPaged(
Arg<QueryFilter<IncomingMail>>.Is.Anything,
Arg<Int32>.Is.Anything,
Arg<Int32>.Is.Anything,
out Arg<Int32>.Out(20).Dummy))
.Callback<QueryFilter<IncomingMail>, Int32, Int32>((p1, p2, p3) =>
{
filterWasNotSpecified = p1 == null;
});
No luck, however. The setup crash with an exception saying Callback arguments didn't match the method arguments. Any suggestion on how to do this? Is there a way to just use the first argument and skip the rest?
Thanks.
You may be running into the following:
“A lambda expression cannot directly capture a ref or out parameter from an enclosing method.”
http://msdn.microsoft.com/en-us/library/bb397687.aspx
Edit: You can create / use a custom delegate … for example declare…
then in your test…