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
public class class1
{
private class2 c2;

public class1()
{
c2 = new class2();
c2.EventReceived += new c2.NotifyEventReceived(this.OnEventReceived);
}

private void OnEventReceived(int a){}
}

public class class2
{
public delegate void NotifyEventReceived(int a);
public event NotifyEventReceived EventReceived;

public class2(){}

}

[Test]
public void test()
{
MockManager.Init();
Mock mockClass2 = MockManager.Mock(typeof(class2));

class1 c1 = new class1();

MockManager.Verify();

}

May i know how to expect call the delegate function - c2.EventReceived += new c2.NotifyEventReceived(this.OnEventReceived); Thankss.. Any idea for it?
asked by clteh9 (5.3k points)

3 Answers

0 votes
If you search the forum for event you would find Checking EventHandlers
answered by scott (32k points)
0 votes
Hi scott,

I have read the forum. I still don't really understand. why the expect call is "add_Click" instead of "buttonTest_Click"?
answered by clteh9 (5.3k points)
0 votes
Let's say add another function in class 2 to call the EventReceived. Eg,

public void callEventReceive(int a)
{
if(EventReceived != null)
{
EventReceived(a);
}
}

May i know how to call the callEventReceive in class2 in order to fire the OnEventReceived in class1 for testing the code inside? Thanksss.
answered by clteh9 (5.3k points)
...