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
In Isolator 6.0.3, method Fails() below fails when expected is that it passes.

[ img ]
[TestClass, Isolated]
public class Tests
{
   public class A
   {
      public event Action<string> StringEvent;
      public void CallStringEventWithNull()
      {
         StringEvent(null);
      }
   }

   [TestMethod]
   public void Passes()
   {
      A a = new A();
      a.StringEvent += (string str) => { };
      a.CallStringEventWithNull();
   }

   [TestMethod]
   public void Fails()
   {
      A a = new A();
      a.StringEvent += (string str) => { };
      Isolate.Invoke.Event(() => a.StringEvent += null, null);
   }

   [TestMethod]
   public void InterestinglyPasses()
   {
      A a = new A();
      a.StringEvent += (string str) => { };
      Isolate.Invoke.Event(() => a.StringEvent += null, (string)null);
   }
}
asked by Neil (27.7k points)

2 Answers

0 votes
Thank you very much for the reproduction. Indeed there is an issue when the passed parameters are not of the expected type, but rather nulls.

We are currently working on this issue, and I will update you as soon as it's fixed. In the mean time you could use your own workaround, as you did in InterestinglyPasses(), by casting the null to the argument type.
answered by igal (5.7k points)
0 votes
Thanks Igal!
answered by Neil (27.7k points)
...