I want to set up the mock to raise the KvpChanged event (with w/ the
method param passed in as the first parameter of the
DR1000EventArgs).
ie if I call SetKvp(100) I want the KvpChanged event to raise w/
DR1000EventArgs(100, whatever);
the quick start says this:
// Causing an event to raise automatically when Submit is invoked
mock.Expect(foo => foo.Submit()).Raises(f => f.Sent += null,
EventArgs.Empty);
I am using Moq 3.0.108.5... so I tried
mock.Setup(foo => foo.SetKvp(It.IsAny<int>())).Raises(f => f.KvpChange
+= null, new DR1000EventArgs(It.IsAny<int>(), It.IsAny<int>()));
but it doesn't like the Raises part - there is no intellisense for the
f => f.??????
thanks
dan
Daniel Cazzulino
unread,
Jan 27, 2009, 4:39:35 AM1/27/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to moq...@googlegroups.com
Will have to review this. Don't remember if the event syntax is supported already in Raises in the beta...
Thanks for reporting and trying out 3.0b !
/kzu from android mobile
andreister
unread,
Jan 27, 2009, 2:29:02 PM1/27/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Moq Discussions
Try Callback:
mock.Setup(foo => foo.SetKvp(It.IsAny<int>()))
.Callback(() => mock.Raise(x => x.KvpChange += null, new
DR1000EventArgs()));
//.Returns(...); - you can add Retuns if the call should return
anything
Daniel Cazzulino
unread,
Feb 3, 2009, 1:28:18 PM2/3/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to moq...@googlegroups.com
I've just committed and uploaded a new release that implements this scenario :) Please take a look and let me know how/if it works for you.
Sample:
mock.Setup(m => m.Submit("foo")) .Raises(
m => m.Submitted += null, (string msg) => new SubmitEventArgs(msg));
-- Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1 425.329.3471
Daniel Cazzulino
unread,
Feb 3, 2009, 1:41:16 PM2/3/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to moq...@googlegroups.com
ok, it's in the trunk still about to upload (will let you know when it's up)
Daniel Cazzulino
unread,
Feb 3, 2009, 4:20:54 PM2/3/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message