Hi Hudson

I'm not sure it was the static factory usage as much as switching from
stubs to mocks. I usually have better luck when I stick to the rule of
only asserting a call was made on a mock, and just use stubs to help
me get there as needed. I also find that even though mock.Expect works
to set up a value, mock.Stub works just as well as conveys intent much
better.

Having said that, you're not using that mock.Expect statement to set
up some value, and so it is redundant with the mock.AssertWasCalled.
Repeat.Once is also the default expectation, so you shouldn't need it
for that either. I could be wrong on this, but you can try commenting
out those two lines and see what happens easily enough.

What about the record/replay semantic is it that you are looking for,
the order in which the two calls are made?



On Jul 16, 8:15 am, Hudson Akridge <[email protected]> wrote:
> The Replay error on AAA was obviously due to me not swapping out from
> my mock repository to the static factory MockRepository.GenerateMock
> (), so that's resolved. AAA works.
>
> Still, I'd like to be able to generate dynamic vs strict mocks, and
> use the repository's record/replay semantics, except it keeps giving
> me that tostring() error when in debug on: mockObject.Replay()
>
> No big deal if not, I can work around for now.
>
> On Jul 16, 9:48 am, Hudson Akridge <[email protected]> wrote:
>
> > AAA gives me the following error: Cannot assert on an object that is
> > not in replay mode. Did you forget to call ReplayAll()
>
> > Here's my test attempting to do this outside of the test fixture (to
> > attempt to eliminate complexities:
>
> >             var mocks = new MockRepository();
> >             var entity = mocks.Stub<AttributeValueEntityBase>();
> >             var attribute = mocks.Stub<Attribute>();
> >             var value = Factory.AttributeValueFactory
> > (AttributeValueType.Text);
>
> >             entity.Expect(x => x.RemoveAttributeValue
> > (value)).Repeat.Once();
> >             value.Owner = entity;
>
> >             attribute.Expect(x => x.RemoveAttributeValue
> > (value)).Repeat.Once();
> >             value.Attribute = attribute;
>
> >             value.Dereference(); //Should and does call both removes
> > for the Owner and Attribute properties on value
>
> >             entity.AssertWasCalled(x => x.RemoveAttributeValue
> > (value)); //Fails here
> >             attribute.AssertWasCalled(x => x.RemoveAttributeValue
> > (value));
>
> > I started off using AAA and was receiving this error, so assumed I
> > needed to be using a record/replay model.
>
> > Regarding the main error of the thread with debugging, I still get the
> > original ToString() error on the .Dereference() call with the above
> > code if I'm stepping through it in debug.
>
> > On Jul 15, 9:26 pm, Kenneth Xu <[email protected]> wrote:
>
> > > Could characteristic a type you actually mean mockAttribute instead?
> > > If that is not the case, would you be able to isolate the issue in a
> > > small reproducable sample?
>
> > > On Wed, Jul 15, 2009 at 6:07 PM, Hudson Akridge<[email protected]> wrote:
> > > >            Expect.Call(() => mockAttribute.RemoveValue
> > > > (Value)).Repeat.AtLeastOnce();
> > > >            characteristic.Replay();
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to