我编写了非常简单的单元测试项目来查看 Microsoft Fakes 的能力。我在系统程序集上执行了菜单命令“添加假程序集”。
public static class Y2KChecker
{
public static void Check()
{
if (DateTime.Now == new DateTime(2000, 1, 1))
throw new ApplicationException("y2kbug!");
}
}
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestYear()
{
using (ShimsContext.Create())
{
ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
Y2KChecker.Check();
}
}
}
但是在使用 (ShimContext.Create()) 时,我总是得到 UnitTestIsolationException:
探查器库“C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0\Microsoft.IntelliTrace.Profiler.11.0.0.dll”中的 SetDetourProvider 返回意外错误。
我的 Visual Studio 2012 Update 2 也安装了 Resharper。如何解决这个异常?
最佳答案
自 2012 年 11 月起,您不能同时运行 Resharper 和 MS Fakes。大约一年前提出了使其兼容的请求。
关于c# - Microsoft Fakes 生成 UnitTestIsolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20686805/