Bill,
Forgive me if I'm wrong but it looks like you might need to take a
step back from your test and think about what it is you're trying to
test. It looks to me like you're having to set up a lot of Mock
objects and I can't actually see the object you're trying to test,
also I can't see any assertions either.

Are all of the mock objects required? can your RegionCollection just
be an actual RegionCollection so you can just add a Region to it?

Often times if you find yourself having to mock loads of objects and
jumping through hoops perhaps you can create a single interface that
your class under test can depend upon, and just mock that. Then create
an actual implementation of your interface that does all the nasty
bits. So if your class under test just requires a Region maybe you can
create some sort of IRegionProvider interface that just has a simple
GetRegion method on it.

Perhaps pasting a complete unit test would also help.

2009/9/9 bill richards <[email protected]>:
>
> I have set my unit test up in the following manner
>
>            var unity = MockRepository.GenerateStub<IUnityContainer>
> ();
>            var presenter =
> MockRepository.GenerateStub<IStatusBarViewPresenter>();
>            var view = MockRepository.GenerateStub<IStatusBarView>();
>            presenter.View = view;
>
>            var eventAggregator =
> MockRepository.GenerateStub<IEventAggregator>();
>            var regionManager =
> MockRepository.GenerateStub<IRegionManager>();
>            var region = MockRepository.GenerateStub<IRegion>();
>            var regionCollection =
> MockRepository.GenerateMock<IRegionCollection>();
>            regionCollection.Add(RegionNames.StatusBarRegion, region);
>
>            regionManager.Stub(r => r.Regions).Return
> (regionCollection);
>
> when I run through the test in debug Mode and set a breakpoint on the
> final line, if I then inspect "regionCollection" it contains zero
> children, instead of the expected "region", now I understand that the
> "regionCollection" is merely a mock object and and when generated the
> MockRepository has no idea about what kind of object it is mocking and
> therefore will not auto-generate the functionality required of the Add
> method.
>
> I am also pretty certain that I can stub the required behaviour,
> unfortunately, I do not know how to do such :o(
>
> Any and all help will be greatly appreciated.
>
> Thanks in advance.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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