I would like to track a method call with Rhino Mocks. Suppose 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; }
And the test looks like this:
// 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 an ExpectedViolationException because the Rhino Mocks framework detects 2 different C classes.
How to test a call if an object under testing creates an object parameter in a test method? Any chance to tell Rhino Mocks to check the parameter as "Equals"?
Thank you, ton!
source share