2012-03-20 85 views
4

我無法找到已被分配的moq和moq contrib的版本。我可能只是在谷歌失敗。Moq和Moq貢獻版本

詳情:

有moq.contrib的版本與版本起訂量4.0.10827,從http://code.google.com/p/moq-contrib/downloads/list最近給了我一個錯誤的原理:

CA0058:引用的程序集「起訂量,Version = 4.0.812.4,Culture = neutral,PublicKeyToken = 69f491c39445e920'找不到。該組件需要分析和被引用:...

或者是有下載起訂量4.0.812.4爲http://code.google.com/p/moq/downloads/list只有4.0.10827

即使無論從安裝的NuGet並沒有幫助的資源。

謝謝。

回答

4

看來Moq Contrib有一個新家:http://moqcontrib.codeplex.com/。沒有下載,也沒有太多有關項目當前狀態的信息。

至少他們知道這個不兼容問題:http://moqcontrib.codeplex.com/discussions/255319 但似乎自去年4月以來沒有修復它,也沒有新的lib庫。

您可以嘗試修復自己的依賴關係並從源代碼構建庫。

或者

我發現這個NuGet包Moq.Contrib.Indy

An independent implementation of the Moq.Contrib project, with up-to-date references to Moq and Autofac

我還沒有嘗試過,但也許值得一試...

+0

似乎工作正常。它增加了一些額外的軟件包tho:Autofac,Autofac.CommonServiceLocator和CommonServiceLocator – NikolaiDante 2012-03-20 16:56:10

+0

不幸的是Moq.Contrib.Indy沒有移動到最新的穩定版本Moq 4.1.1309.1617。在任何情況下,解決方案都不應該嚴格依賴版本。 – 2013-09-19 20:58:56

4

我固定它以下列方式。

  1. 爲源從

http://code.google.com/p/moq-contrib/downloads/detail?name=Moq.Contrib-0.2-src.zip

  • 然後更改目標框架4.0

  • 添加的起訂量4.0,而不是現有的起訂量

  • 評論「ve rify「和」VerifyAll「方法。有方法是虛擬的2.0起訂量的contrib

  • 重命名方法調用

  • MockFactory到MockRepository ExpectGet到SetupGet

有在項目Autofac參考。我沒有嘗試改變這個參考到最新的autofac。

+0

我試過Nitin的解決方案。但是Moq Contrib中缺少ContextSpecification的定義。我不得不明確地將它添加到圖書館。之後,這些步驟工作正常。 – user2478528 2013-06-12 13:32:56

0

您可以在應用中設置bindingRedirect。config:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> 
     <bindingRedirect oldVersion="4.0.0.0-4.2.1312.1622" newVersion="4.2.1312.1622" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

其中4.2.1312.1622應該用最新的Moq版本代替。