Browsing the archives for the rhino mocks tag.


Rhino Mocks Arg<T> Error

Software

In hindsight, this one was easy to predict.  Running a test with the following lines in record mode:

rd.LogMessage(Arg<MessageImportance>.Is.Anything, Arg<string>.Is.Anything);
LastCall.IgnoreArguments().Repeat.Any();

I got the error:

Failed    Execute_1    Cornbread.MSBuild.Tasks.Test    Test method Cornbread.MSBuild.Tasks.Test.RestoreDatabaseTest.Execute_1 threw exception:  System.InvalidOperationException: Use Arg<T> ONLY within a mock method call while recording. 2 arguments expected, 4 have been defined..

The obvious problem: I’m using Arg<T> when I should be using NULL to indicate “don’t care” parameters to the expected call:

rd.LogMessage(MessageImportance.Normal, null);
LastCall.IgnoreArguments().Repeat.Any();

1 Comment