You can use DI to inject the view mock into the presenter. Then you need to call the Present method of the presenter. The third step is to assert that certain methods of the view have been called.
// arrange IView viewMock = MockRepository.GenerateMock<IView>(); // act var target = new Presenter(viewMock); target.Present( /* may be some data as an argument */ ); // assert viewMock.AssertWasCalled(view => view.ShowList(null), call => call.Constraints( /* you can use List constraint here to ensure args are correct */ )); On Mon, Dec 15, 2008 at 9:15 PM, [email protected] < [email protected]> wrote: > > Actually, I would like to mock the view. > > The presenter does some work and presents the view with: > 1. A List. > -- I would like to be able to test that the list has the correct > number of items and that each item has the correct state > 2. A class > -- I would like to verify that the class has the correct state > > On Dec 12, 9:29 pm, "Shane Courtrille" <[email protected]> > wrote: > > Is this class something that your Presenter is generating? Or is it > being > > provided to your presenter by another source (Repository.. Proxy) which > > would have been provided to the presenter as a mock? > > > > If it's the 1st then you would want to capture the instance and assert > > against it. In this case you are only going to be using rhino mocks to > get > > you the actual object. > > > > If its the 2nd then you have control over the source instance and all you > do > > is once again capture the value that was passed to your view and assert > that > > its the same instance you passed to the presenter in the first place. Of > > course if you make any changes and you can't do a simple assertion you > will > > need to assert each property. > > > > On Fri, Dec 12, 2008 at 6:52 PM, [email protected] < > > > > > > > > [email protected]> wrote: > > > > > what happens when we mock the View (in MVP) and the presenter sends a > > > class to the View? > > > > > using Rhino Mocks, how does one check that this class has the right > > > data in it? Is mocking even the correct tool to be using for this?- > Hide quoted text - > > > > - Show quoted text - > > > -- Software modules coupling is the path to the dark side. Coupling leads to complexity. Complexity leads to confusion. Confusion leads to suffering. Once you start down the dark path, forever will it dominate your destiny, consume you it will! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
