In the scenario pictured below, a CallOriginal()'d static method is called from a constructor invoked via Isolate.Fake.Instance<AbstractClass>(Members.CallOriginal).
As you can see from console output "StaticClass.StaticMethod() called", StaticClass.StaticMethod() is called, but Isolator appears to not record in its internal call history data structure that this call took place, leading to test failure upon asserting that StaticClass.StaticMethod() was called:
Is this behavior intended? I was hoping to be able to test an abstract class's constructor without resorting to a hackish testing-only subclass which would have a directly invokable constructor - with directly invoked constructors not exhibiting this unexpected behavior:
First screenshot as text:
using System;
using NUnit.Framework;
using TypeMock.ArrangeActAssert;
public static class StaticClass
{
public static void StaticMethod()
{
Console.WriteLine("StaticClass.StaticMethod() called");
}
}
public abstract class AbstractClass
{
public AbstractClass()
{
StaticClass.StaticMethod();
}
}
[TestFixture, Isolated]
public class Tests
{
[Test]
public void Test()
{
Isolate.WhenCalled(() => StaticClass.StaticMethod()).CallOriginal();
//
Isolate.Fake.Instance<AbstractClass>(Members.CallOriginal);
//
Isolate.Verify.WasCalledWithExactArguments(() => StaticClass.StaticMethod());
}
}