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
In Isolator 6.0.1 this behavior happens:

[ img ]
[TestClass, Isolated]
public class Tests
{
   public class A
   {
      public A()
      {
         B b2 = new B();
      }
   }

   public class B
   {
      public void BMethod()
      {
      }
   }

   [TestMethod]
   public void Test()
   {
      B b1 = Isolate.Fake.Instance<B>();
      Isolate.Fake.Instance<A>(Members.CallOriginal, ConstructorWillBe.Called);
      Isolate.Verify.WasCalledWithExactArguments(() => b1.BMethod());
   }
}
asked by Neil (27.7k points)

2 Answers

0 votes
Hi Neil,

This is indeed a bug - for some reason we override the faked instance of B with the one in the A constructor. I'm logging a bug for this into our tracking system. I am however assigning it a relatively lower priority as the use case is pretty rare and it's easy to work around (fake A before B, for instance).

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Thanks Doron. Faking A before B worked in my real code to make the test pass.
answered by Neil (27.7k points)
...