I can't comment on the issue specifically as I'm not in a place to try this issue myself. I'm curious what happens if you instead of using mockObject.Replay() you instead create mocks/stubs from the AAA syntax where this is done for you.
I will try to get to this at some point but have been unable to give the time this list deserves. Tim On Wed, Jul 15, 2009 at 5:07 PM, Hudson Akridge <[email protected]> wrote: > > I'm on Version 3.5 for .NET 3.5. > > I have a situation where I'm able to utilize RhinoMocks in my tests as > long as I don't run my test in debug and break before a > mockObject.Replay() is called. If run without debug or breaking before > that point, no issues, everything works as expected, test is green. If > I do, and I'm in debug, I get the error mentioned in the subject, my > guess is because in debug it must get the string representation of the > object to display in the locals window. > > Scenario: > I have a test fixture, which builds certain components required on a > class I'm testing, it also creates a fluent interface, and allows me > to specify my asserts in English (eg .ShouldHaveValueOf(value)) as > well as greatly increasing the readability and maintainability of my > tests. I recently (today) set up the test fixture to build mock > objects for dependencies and build the Expect.Call() methods for each > mock it creates depending on the situation. Because of the dynamic > nature of the test fixture being able to build different expectations > on the mocks depending on what the test needs, the Fixture will call > entity.Replay() on each mocked object explicitly. Here's an example of > the test: > public void TestMethod() > { > classTestFixture.AssociateToEntity().AssociateToAttribute() > .Dereference() > .WasRemovedFromEntity() > .WasRemovedFromAttribute(); > } > > public class Fixture > { > public Fixture AssociateToEntity() > { > Expect.Call(() => mockEntity.RemoveValue > (Value)).Repeat.AtLeastOnce(); > entity.Replay(); > Value.Owner = mockEntity; > > return this; > } > > public Fixture AssociateToAttribute() > { > Expect.Call(() => mockAttribute.RemoveValue > (Value)).Repeat.AtLeastOnce(); > characteristic.Replay(); > Value.Attribute = mockAttribute; > > return this; > } > } > > The classTestFixture sets up my test object automatically, then > associates it to an Entity and an Attribute. Each of those calls > registers a mock object of an appropriate type with the mockRepository > and states their expectation (that remove() is called at least once), > then calls mockEntity.Replay() and mockAttribute.Replay(). > > If I'm not in Debug mode, it gets past this point and everything's > hunky dory. If I'm in debug mode and I'm stepping before this point, I > get the error. > > I am overriding .ToString() on both my Entity and Attribute. > > If I use mocks.ReplayAll(), I have no issue. However, the reason I'm > trying to avoid this, is because of the piecemeal nature with which > the fixture goes about putting all the test pieces (and mocks) > together. Because of .ReplayAll() working, it leads me to believe that > there might be only an issue with breaking in debug during a > mockObject.Replay() call. > > > > -- Tim Barcz ASPInsider http://timbarcz.devlicio.us http://www.twitter.com/timbarcz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
