chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hello,

As another feature, I would like the ability to verify an event call, as in the format of:

Isolate.Verify.EventWasFired<A>(..);

This would allow me to ensure a method calls an event.

Thanks.
asked by bmains (13.2k points)

3 Answers

0 votes
Hi Brian,

This feature is already planned for a future version of Isolator - good to know its needed
answered by dhelper (11.9k points)
0 votes
actually, there is an easy way to check if an event was raised.
you subscribe to the event in your test, and in the event handler you set a boolean flag to true. then you just assert on the flag.

here is a quick example:

public void Test()
{
bool wasRaised=false;
var button = new Button;
button.Click += ()=> wasRaised=true;

button.DoSomethingThatShouldHaveTriggeredTheEvent();
Assert.IsTrue(wasRaised);
}



if you were asking about how to *raise* a fake event from the test that is indeed a feature we are planning for future releases.
answered by royo (2k points)
0 votes
actually, there is an easy way to check if an event was raised.
you subscribe to the event in your test, and in the event handler you set a boolean flag to true. then you just assert on the flag.


Thanks, that's the approach I've been taking.
answered by bmains (13.2k points)
...