tags:

views:

19

answers:

1

I've got the following line, attempting to create a mock of a concrete type:

AddPropPersonalCOI = MockRepository.GenerateMock<SomeType>(ObjectFactory.GetInstance<paramType1>(), ObjectFactory.GetInstance<paramType2>());

Assert.IsNotNull(AddPropPersonalCOI.view);

I've actually stepped into the constructor in question, watched it execute, watched the view property get assigned from the value passed into the constructor (which I verified were not null), and yet the assert fails.

And yes, view is virtual.

Anyone know what I'm doing wrong?

+1  A: 

If view is virtual, you'll need to set an expectation for it before you can use it. Rhino Mocks gives you null values when you call methods and properties in expectations mode.

Tim Robinson
Makes perfect sense now that I think about it. Thanks!
Adam