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
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 Neil (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 ohad (35.4k points)
0 votes
Hi Ohad,

The class is decorated with [Isolated] but the event is not invoked.
answered by Neil (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 ohad (35.4k points)
0 votes
6.0.4
answered by Neil (27.7k points)
...