开发者

Dynamically Subscribing to Events in RhinoMocks

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开发者_如何学JAVA(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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜