I would like to track a call to a method with Rhino Mocks. Let's assume I have this code:
public class A
{
protected IB _b;
public A(IB b)
{
_b = b;
}
public void Run( string name )
{
_b.SomeCall(new C { Name = name });
}
}
public interface IB
{
void SomeCall( C c );
}
public class C
{
public string Name { get; set; }
// more attributes here
}
And the test looks like:
// prepare
var bMock = Rhino.Mocks.MockRepository.GenerateStrictMock<IB>();
bMock.Expect(x => x.SomeCall(new C { Name = "myname" }));
var sut = new A(bMock);
// execute
sut.Run("myname");
// assert
bMock.VerifyAllExpectations();
The test fails with a ExpectedViolationException because Rhino Mocks framework detects 2 distinct C classes.
How do I check the call if the subject under tests creates the object parameter into the method under test? Any chance to tell Rhino Mocks to check the parameter as "Equals"?
Thanks a ton!