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.
精彩评论