The problem probably lies with object class defined in mscorlib. I defined a derived class with overriden Equal method. If the derived class the equals test worked.
On Feb 4, 4:08 pm, Alex McMahon <[email protected]> wrote: > I think there is a limitation on mocked 'object' as I recall it was due to > some limitation in dynamic proxy. I think you get the same or similar > problem if you try and mock object.ToString() > > On 4 February 2010 13:36, bill richards <[email protected]>wrote: > > > > > [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]<rhinomocks%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rhinomocks?hl=en.- Hide quoted text - > > - Show quoted text - -- 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.
