I thought Rhino Mocks could stub/mock object.ToString():
http://ayende.com/Blog/archive/2005/07/12/RhinoMocks201MinorBugFixes.aspx
But someone recently tweeted that they couldn't get it working. I
threw together a quick test with both AAA and record/replay and I
can't get it working either:
[TestFixture]
public class Tests
{
[Test]
public void StubToString_AAA()
{
var obj = MockRepository.GenerateStub<object>();
obj.Stub(x => x.ToString()).Return("my-tostring");
Assert.That(obj.ToString(), Is.SameAs("my-tostring"));
}
[Test]
public void StubToString_RecordReply()
{
var repository = new MockRepository();
var obj = repository.Stub<object>();
obj.Expect(x => x.ToString()).Return("my-tostring");
repository.ReplayAll();
Assert.That(obj.ToString(), Is.SameAs("my-tostring"));
repository.VerifyAll();
}
}
In both tests, I get the following error on the obj.Stub() and the obj.Expect():
System.InvalidOperationException: 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).
Should this work?
--
Patrick Steele
http://weblogs.asp.net/psteele
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---