开发者

How do I raise an event from a mole using MS Moles?

The Moles documentation describes how to raise events on class stubs but the same method doesn't work with a full Mole. You开发者_Python百科 can add a delegate to the add / remove methods, but you can't manually raise the event.

The only solution I can think of is to create a RaiseEvent() method on the class being tested, but that kinda defeats the point of using moles.

Any suggestions?


It turns out you can Mole the Add method on the event and grab the event handler there. Once you have the event handler, you can just Invoke it manually, simulating the event.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜