I am trying to write a test that covers my error handling in a specific class. This class listens for the Error event with the following signature:
OnError(int ErrorNumber, string ErrorText, ref bool retry)
The problem is the ref bool variable at the end. I use Rhino Mocks to create a mock interface for testing, and when I try to raise an error using the following:
bool retry = false; AdapterMock.Raise(x => x.Error += null, 0, "0", ref retry);
It will not even compile, telling me that it cannot convert from ref bool to Object.
If I changed my signature to:
bool retry = false; AdapterMock.Raise(x => x.Error += null, 0, "0", retry);
I compile fine, but the test does not work with System.InvalidOperationException: parameter # 3 is System.Boolean, but should be System.Boolean &
I am pulling my hair on it, how to properly raise this event in my layout?
source share