AssertWasCalled with set property sees property as "null"

54 views
Skip to first unread message

Adam

unread,
Jun 26, 2012, 12:25:08 PM6/26/12
to rhino...@googlegroups.com
Hey all,

I'm trying to AssertWasCalled a certain method of a mocked (not stubbed) class, but the properties in it get reset to null.

I have:
          Foo foo = MockRepository.GenerateMock<Foo>();
Foo_Accessor fooAccessor = Foo_Accessor.AttachShadow(foo) // It's a private property, so I set it with an Accessor 
fooAccessor.Property = MockRepository.GenerateMock<PropertyClass>();
          // Do stuff that makes a call in foo.Method()
// This stuff successfully runs foo.Method() with the foo.Property set as the proxy
foo.AssertWasCalled(x => x.Method(""), o => o.IgnoreArguments());

However, when it runs x.Method(""), it shows foo.Property as being null.  Can I force-inject this property in the call? Or is there a way to permanently set it beforehand?
I think the fact that I have to use an Accessor.AttachShadow makes it more complicated...

Thanks for the help!
--Adam
 



            

Adam

unread,
Jun 26, 2012, 3:32:34 PM6/26/12
to rhino...@googlegroups.com
Also related, but mostly a side question, is can I make the Accessor a mock accessor and still AttachShadow(foo) with it?  If it's a mock accessor it doesn't get access to the AttachShadow method, so is there another way to set that up?

Thanks again!
--Adam
Reply all
Reply to author
Forward
0 new messages