views:

71

answers:

1

We're currently migrating from NMock2 to RhinoMocks and we're having trouble replicating this code:

foreach (EventInfo e in typeof(MarketMapPopupIMVPView).GetEvents())
    Expect.Once.On(mockView).EventAdd(e.Name, new TypeMatcher(typeof(EventHandler)));

Essentially this was placed inside a template for MVC controls to ensure that developers using the template were actually wiring up events in the Presenter that were listed in the View. The problem is that we don't know the events before-hand and place the expectation by name which we can't seem to find a way to do in RhinoMocks.

+1  A: 

I've done some stuff like this in the past, but determined in most cases it's just not worth it. Writing your own stub will take less time and effort and be more expressive and understandable. I wrote a post about it. This might help.

http://blog.coreycoogan.com/2009/11/11/event-mocking-without-rhino-mocks/

Corey Coogan