A little digging around indicates that your thoughts are correct, it
seems that I will instead have to construct my own MockUnityContainer

On Sep 8, 1:56 pm, "Kenneth Xu" <[email protected]> wrote:
> I don't use Unity but is the Resolve a virtual method? In general, M$ mostly 
> (if not all) uses non-virtual implementation.
>
> Sent from my Verizon Wireless BlackBerry
>
>
>
> -----Original Message-----
> From: bill richards <[email protected]>
>
> Date: Tue, 8 Sep 2009 05:42:50
> To: Rhino.Mocks<[email protected]>
> Subject: [RhinoMocks] System.InvalidCastException: Unable to cast object of
>
>  type  'ObjectProxy
>
> Am I really rubbish at searching the internet or what? I cannot find
> any decent introductory documentation for Rhino Mocks anywhere!
>
> I get the following exception when running the test below and I can
> find no reference to this exception on the internet (but my rubbish-
> ness(?!) at internet searching has already been highlighted).
>
> System.InvalidCastException: Unable to cast object of type
> 'ObjectProxy86f050dbad4c447788658ebb5b463d54' to type
> 'Microsoft.Practices.Composite.Events.IEventAggregator'
>
> THE TEST:
>
>         private const string MessageSent = "Services Module
> Initialized";
>
>         [Test]
>         public void
> WhenInstantiated_ShouldCallIStatusMessageServicePublishMessage()
>         {
>             var unity = MockRepository.GenerateStub<UnityContainer>();
>
>             var aggregator =
> MockRepository.GenerateStub<IEventAggregator>();
>             var service =
> MockRepository.GenerateStub<IStatusMessageService>();
>             var region = MockRepository.GenerateStub<IRegionManager>
> ();
>
>             unity.Stub(container => container.Resolve<IEventAggregator>
> ()).Return(aggregator); // throws exception
>             unity.Stub(container => container.Resolve<IRegionManager>
> ()).Return(region);
>             unity.Stub(container =>
> container.Resolve<IStatusMessageService>()).Return(service);
>
>             new ServicesModule(unity).Initialize();
>
>             unity.AssertWasCalled(container =>
> container.Resolve<IStatusMessageService>());
>             unity.AssertWasCalled(container =>
> container.Resolve<IEventAggregator>());
>             service.AssertWasCalled(messageService =>
> messageService.PublishStatusMessage(MessageSent));
>         }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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