[Test]
public void TestEquals()
{
// Arrange
var someObject = MockRepository.GenerateMock<Object>();
var someParameter = MockRepository.GenerateMock<Object>();
someObject.Expect(x
=>x.Equals(someParameter)).Return(false);
// Act
var result = someObject == someParameter;
// Assert
Assert.That(result, Is.False);
someObject.VerifyAllExpectations();
}
The above would be the preferred syntax, however, as Tim pointed out,
it's not testing aything!
Though I am a little confused as to why the exception is thrown since
Equals is deffinately a virtual member.
On Feb 4, 12:12 pm, BB <[email protected]> wrote:
> The error in the exception is "Invalid call, the last call has been
> used or no call has been made (make sure that you are calling a
> virtual (C#) / Overridable (VB) method)."
>
> Sample code
> [Test]
> public void TestEquals()
> {
>
> MockRepository mocks = new MockRepository();
> // example
> Object someObject = mocks.CreateMock<System.Object>();
> Object someParameter = mocks.CreateMock<System.Object>();
> //Exception occurs on the line below Expect.Call
>
> Expect.Call<Object>(someObject.Equals(someParameter)).Return(false);
> mocks.ReplayAll();
> Assert.IsTrue(someObject.Equals(someParameter));
> }
--
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.