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
I have the problem to fake a call to an event. I use NUnit as well. Here is the code:

[Test, Isolated]
public void TestEventCall
{
    ... some definitions

     string resultingServer, resultingItem;
     int resultingValue;

    // here I set up the listener
    opc.OnEventFired += (server, itemName, value) =>
                                    {
                                        resultingServer = server;
                                        resultingItem = itemName;
                                        resultingValue = value;
                                    }

  Isolate.Invoke.Event (() => opc.OnEventFired += null, serverName, itemName, 200);

  Assert.AreEqual (resultingServer, serverName);
  Assert.AreEqual (resultingItem, itemName);
  Assert.AreEqual (resultingValue, 200);
}


The issue is it does not compile. The error states that the event is not supported and I shall use the accessor methode 'add_OnEventFired'.
The event is however public at the class to be tested.

Can anyone help me here?
asked by mph (6k points)

1 Answer

0 votes
Hello,

I'm sorry for the late reply, could you please post the definition of the opc class, particularly how the event is defined?

Best could be if you could send us a small repro to support@typemock.com
answered by igal (5.7k points)
...