Hi!
I tried EasyMockNET and it's very cool stuff, but how can I deal with events in EasyMockNET ?
Example:
I want to mock interface:
ISomeInterface
{
void DoSomething();
event DoCallback;
}
Now when a real object uses this mock my test fails with exception
"Unexpected method call add_DoCallback(System.EventHandler`1 DataEventArgs`1):
add_DoCallback(System.EventHandler`1 DataEventArgs`1): expected: 0, actual: 1".
How can I aviod this ? How should I add expectations on events ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, add an expectation on an event by subscribing to it just as you'd call a method. Just think of += and -= as method calls - that's what they are, really.
Jon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I tried EasyMockNET and it's very cool stuff, but how can I deal with events in EasyMockNET ?
Example:
I want to mock interface:
ISomeInterface
{
void DoSomething();
event DoCallback;
}
Now when a real object uses this mock my test fails with exception
"Unexpected method call add_DoCallback(System.EventHandler`1 DataEventArgs`1):
add_DoCallback(System.EventHandler`1 DataEventArgs`1): expected: 0, actual: 1".
How can I aviod this ? How should I add expectations on events ?
Yes, add an expectation on an event by subscribing to it just as you'd call a method. Just think of += and -= as method calls - that's what they are, really.
Jon