My object under test has two dependency objects of the same type. Sometimes when a test has a failed expectation, it's not clear which dependency object set that expectation. Is there some way to give the dependency objects names that will appear in the error messages so that I can tell them apart?
Here's an example:
MockRepository mocks = new MockRepository();
var xAxis = mocks.StrictMock<IAxis>();
var yAxis = mocks.StrictMock<IAxis>();
Ball ball;
using (mocks.Record())
{
Expect.Call(xAxis.Velocity).Return(100);
Expect.Call(yAxis.Velocity).Return(0);
}
using (mocks.Playback())
{
ball = new Ball(xAxis, yAxis);
ball.Bounce();
}
Now if there's something wrong with the Bounce code, I might get a message like this:
Rhino.Mocks.Exceptions.ExpectationViolationException : IAxis.get_Velocity(); Expected #1, Actual #0.
I can't easily tell which axis got missed.