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
This Isolate.Invoke.Event call does not invoke A.IntEvent. Expected is that an Exception is thrown.

[ img ]

[TestClass, Isolated]
public class Tests
{
  class A
  {
     public event Action<int> IntEvent;

     public A()
     {
        IntEvent += (int i) => 
        {
           throw new Exception();            
        };
     }
  }

  [TestMethod]
  public void Test()
  {
     A a = new A();
     Isolate.Invoke.Event(() => a.IntEvent += null, 0);
  }
}
asked by (27.7k points)

4 Answers

0 votes
Hi Neil,
In order the invoke event with the Isolator you have to decorate the class or the test method with the Isolated attribute.

This will work:
[TestMethod, Isolated]
public void Test()
{
     A a = new A();
     Isolate.Invoke.Event(() => a.IntEvent += null, 0);
} 
answered by (35.5k points)
0 votes
Hi Ohad,

The class is decorated with [Isolated] but the event is not invoked.
answered by (27.7k points)
0 votes
Hi Neil,
Oops sorry, I didn't notice the attribute at your code :oops:
However the same test behaved as expected (throw the exception) when I run it .
What version of the Isolator are you using?
answered by (35.5k points)
0 votes
6.0.4
answered by (27.7k points)
...