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 6.0.1, this code doesn't throw an expected NestedCallException:

[ img ]
public class A
{
  public AFormatFileWriter FileWriter { get; private set; }

  public A()
  {
     FileWriter = new AFormatFileWriter();
  }

  public void Method()
  {
     FileWriter.WriteToFile();
  }

  public class AFormatFileWriter
  {
     public void WriteToFile()
     {
     }
  }
}

[TestMethod]
public void Test()
{
  Isolate.Swap.AllInstances<A>().With(
     Isolate.Fake.Instance<A>());
  A a = Isolate.Fake.Instance<A>(Members.CallOriginal);
  //
  a.Method();
  //
  Isolate.Verify.WasCalledWithExactArguments(() => 
     a.FileWriter.WriteToFile());
}
asked by Neil (27.7k points)

4 Answers

0 votes
Neil,

I don't think you should receive a NestedCallException here - there's no nesting involved. What I would expect is for the test to pass, but we may have a bug with swapping nested types. I will log the issue and investigate.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Hi Doron,

Isn't "FileWriter.WriteToFile()" nested under the call to "a.FileWriter"?
answered by Neil (27.7k points)
0 votes
Hi Neil,

It's not a nested call:
a.FileWriter.WriteToFile()

This is a chain and it's a feature supported by Isolator.

If for example you'd have:
a.FileWriter.WriteToFile(GetFile())

Then GetFile() would have been a nested call.

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Hi Elisha,

Thanks for the clarification.
answered by Neil (27.7k points)
...