我对FakeItEasy很陌生,一般都是在嘲笑别人。我创建了一个Visual 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’在当前上下文中不存在”。
我遗漏了什么?
发布于 2011-04-12 21:09:27
事实证明,有必要创建在模拟中引用的接口。它们不是自动生成的。
然而,可以指定要实现的其他接口:
var foo = A.Fake<IFoo>(x => x.Implements(typeof(IComparable)).Implements(typeof(IFormattable))); https://stackoverflow.com/questions/5639472
复制相似问题