Hi,
I'm fairly new to rhino mocks, so apologies in advance if this is
dumb.
I am constructing a mock for a method with a ref parameter that points
to an array. My mocking code looks like this:
var outArray = new[]{new RequestObject{...}, new RequestObject{...},
new RequestObject{...};
var qp = MockRepository.GenerateMock<IProcessor>();
qp.Expect(x => x.myMethod(ref
reqArray)).Return(false).OutRef(outArray);
When I run the test, this fails with an error "Cannot cast object of
type RequestObject to type RequestObject[]".
I puzzled around for ages, and found I could get the test to run if I
change the third line to:
qp.Expect(x => x.myMethod(ref reqArray)).Return(false).OutRef(new[]
{outArray});
It looks as if RM thinks I am giving it an array of parameters, but as
there's only one ref parameter, it is attempting to return the first
item and discard the rest. However, according to the docs I read, the
way to specify multiple OutRef's is to use .OutRef(item1, item2,
item3) so I don't see why my first attempt didn't work.
It works with my workaround, but is it a bug?
BTW, it was very quick to get started with rhino, for which I am very
grateful.
Cheers,
Miles
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.