0

我是 FakeItEasy 的新手,而且一般都在嘲笑。我创建了一个 Visual Studio 2010 C# 类库项目。我添加了对 NUnit DLL 和 FakeItEasy DLL 的引用。我为两者都添加了“使用”语句,然后尝试尝试一些文档示例。我的代码是:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FakeItEasy.Core;
// ...
using NUnit.Framework;

namespace TestLib
{
    [TestFixture]
    public class Tester
    {
        [Test] 
        public void SomeTest() 
        {
            ISomething mockThing = A.Fake<ISomething>(); 
            /*
            ...
             */
        }

    }
}

我收到错误“找不到类型或命名空间名称‘ISomething’ ”和“当前上下文中不存在名称‘A’。”

我错过了什么?

4

1 回答 1

0

事实证明,有必要创建模拟中引用的接口。它们不是自动生成的。

但是,可以指定要实现的其他接口:

var foo = A.Fake<IFoo>(x => x.Implements(typeof(IComparable)).Implements(typeof(IFormattable))); 
于 2011-04-12T21:09:27.123 回答