2011-04-12 31 views
0

我是FakeItEasy和一般嘲笑的新手。我創建了一個Visual Studio 2010 C#類庫項目。我添加了對NUnit DLL和FakeItEasy DLL的引用。我爲兩者添加了「使用」語句,然後試圖嘗試一些文檔示例。我的代碼是:「名字‘A’並不在當前的背景下存在」FakeItEasy模擬界面找不到

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’找不到」和

我錯過了什麼?

+0

好吧,我解決的錯誤之一。關於「A」不存在的消息是因爲我需要添加命名空間「FakeItEasy」。 – Buggieboy 2011-04-12 19:11:20

回答

0

事實證明,有必要創建在模擬中引用的接口。它們不是自動生成的。

它,但是,可以指定其他接口來實現:

var foo = A.Fake<IFoo>(x => x.Implements(typeof(IComparable)).Implements(typeof(IFormattable)));