运行单元测试时,我在ShimsContext.Create上遇到StackOverflowException。在下面的代码中,我可以打破Thread.Sleep(0),所以我知道ShimsContext.Create正在引发异常。我已经评论了其他所有内容。知道为什么会这样或者如何解决它?
[TestMethod]
public void MyTest()
{
Thread.Sleep(0);
using (ShimsContext.Create())
{
//commented out test logic that needs shims
}
}
溢出的堆栈看起来像:
Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.ProtectingContext.ProtectingContext() + 0x1f bytes
Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.AcquireProtectingContext() + 0x2d bytes
Microsoft.QualityTools.Testing.Fakes.dll!Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.TraceProfilerInstrumentationProvider.DetourProvider(object receiver, System.RuntimeMethodHandle methodHandle, System.RuntimeTypeHandle declaringTypeHandle, System.RuntimeTypeHandle[]
这三个电话无限重复。