开发者

Dynamically Subscribing to Events in RhinoMocks

开发者 https://www.devze.com 2022-12-18 14:27 出处:网络
We\'re currently migrating from NMock2 to RhinoMocks and we\'re having trouble replicating this code:

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

精彩评论

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

关注公众号