开发者

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

开发者 https://www.devze.com 2023-01-24 03:54 出处:网络
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 ca

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

精彩评论

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