IMHO, Rhino Mocks produces an unclear diagnostic message when AssertWasCalled is used in order to verify that a method has been called with a specific argument.
Example:
interface ISomeInterface
{
void Write(string s);
}
[TestFixture]
public class SomeTests
{
[Test]
public void WriteShouldBeCalledWithCorrectArguments()
{
// Arrange
var mock = MockRepository.GenerateMock<ISomeInterface>();
var sut = new SomeClass(mock);
// Act
sut.DoSomething();
// Assert
mock.AssertWasCalled(x => x.Write(Arg<string>.Is.Equal("hello")));
}
}
Now, if the test fails with this message...
Rhino.Mocks.Exceptions.ExpectationViolationException : ISomeInterface.Write(equal to hello); Expected #1, Actual #0.
... you cannot know if it fails because
A. 'Write' is never invoked -or-
B. 'Write' is in fact invoked but with the incorrect argument
If B would be the cause of the failure then it would be so much clearer if the message would read something like this:
Rhino.Mocks.Exceptions.ExpectationViolationException : ISomeInterface.Write(string arg): Method was called but with the incorrect arguments: Expected: hello, Actual: bye
Can I fix this shortcoming myself (by writing custom matchers for Rhino in some way) or do I simply have to write a manual mock for this?