Reflecting on MoQ, I'm not exactly sure how the MockedEvent class can
be used as the event handler itself; that seems bizarre to me.
However, once you get past that, it seems pretty straight forward how
the invocation list is run (side note: you guys do 'foreach' it. If
I could only repro that exception...).
It seems like the easy part is raising the event, the hard part is
getting the compiler not to choke when you add the MockedEven as an
event handler if the MockedEvent doesn't match the expected
signature. I don't understand how the compiler doesn't choke on it
already, so I can't figure out a way to mock any type of event.
On Sep 8, 2:30 pm, "Daniel Cazzulino" <
dan...@cazzulino.com> wrote:
> creating the generic watcher is the easy part.
> thing is, for mocks, you typically want to RAISE the event, which is nowhere
> as straightforward (need to have a way to do it from the mock instance)
>
> On Mon, Sep 8, 2008 at 3:02 PM, yesthatmcgurk <
yesthatmcg...@gmail.com>wrote:
>
>
>
>
>
> > I was messing around, trying to create a dynamic way to watch an event
> > to see if it fired. With some fine google fu I was able to create a
> > dynamic event handler and attach it to any kind of event, be it
> > generic or not. Here's a link to a solution containing the class and
> > the barest of tests:
>
> >
http://cid-f8be9de57b85cc35.skydrive.live.com/self.aspx/Public/Dynami...
>
> > I was thinking... maybe this could be used to create a mocked event
> > invoker for any type of event, rather than just generic events?
>
> > I haven't spent much time looking at your mocked event invokers, so I
> > don't know how complex the process is. I suppose if it is trivial you
> > can snag out the IL and repro the calls when generating the dynamic
> > event handler. I might look closer at it, tho I've wasted enough time
> > on it today, probably.- Hide quoted text -
>
> - Show quoted text -