本文介绍了Microsoft Fakes 生成 UnitTestIsolationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了非常简单的单元测试项目来查看 Microsoft Fakes 的功能.我在系统组件上执行了菜单命令添加假冒组件".

I have written very simple unit test project to see abilities of Microsoft Fakes. And I have executed on System assembly the menu command "Add Fakes Assembly".

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:

But in line using (ShimContext.Create()) I get always the UnitTestIsolationException:

我的 Visual Studio 2012 Update 2 也安装了 Resharper.如何修复此异常?

With my Visual Studio 2012 Update 2 is also installed Resharper. How fix this exception?

推荐答案

截至 2012 年 11 月,您不能同时运行 Resharper 和 MS Fakes.大约一年前提出了使其兼容的请求.

As of November 2012 you cannot run Resharper and MS Fakes at the same time. A request to make it compatible was put in almost a year ago.

http://devnet.jetbrains.com/message/5470396?tstart=0

这篇关于Microsoft Fakes 生成 UnitTestIsolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 08:12