I am trying to write a test that covers my error handling in a particular class. This class is listening for an Error event with the following signature:
OnError(int ErrorNumber, string ErrorText, ref bool retry)
The problem is with the ref bool variable at the end. I am using Rhino Mocks to create a mock interface for testing and when I try to raise the error using the following:
bool retry = false;
AdapterMock.Raise(x => x.Error += null, 0, "0", ref retry);
It won't even compile, telling me it can't convert from ref bool to Object.
If I change the signature to:
bool retry = false;
AdapterMock.Raise(x => x.Error += null, 0, "0", retry);
I compiles fine but the test fails with System.InvalidOperationException : Parameter #3 is System.Boolean but should be System.Boolean&
I'm pulling my hair out on this one, how do I properly raise this event in my mock?