不能使用.net framework 4.5伪造sharepoint dll [英] can't fakes sharepoint dll using .net framework 4.5

查看:105
本文介绍了不能使用.net framework 4.5伪造sharepoint dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Fakes来隔离我的代码。我的测试项目是使用.net framework 4.5。当我尝试为Microsoft.SharePoint(2013)添加fakes程序集时,它会抛出异常,例如''Microsoft.SharePoint.WebControls.Fakes.StubSPCalendarBase.ItemType'':无法覆盖,因为''Microsoft.SharePoint.WebControls.SPCalendarBase .ItemType''不是属性[C:\CopyProjet \6.2 \ WebParts \UnitTestProject3 \obj \Debug \Fakes\msp\f.csproj]。



顺便说一句,我知道当测试项目的.net框架是4.0时会没问题。

I am using Fakes to isolate my code. My test project is using .net framework 4.5. When I try to add fakes assembly for "Microsoft.SharePoint"(2013), it throw exception likes "''Microsoft.SharePoint.WebControls.Fakes.StubSPCalendarBase.ItemType'': cannot override because ''Microsoft.SharePoint.WebControls.SPCalendarBase.ItemType'' is not a property [C:\CopyProjet\6.2\WebParts\UnitTestProject3\obj\Debug\Fakes\msp\f.csproj]".

Btw, I know that it will be fine when the .net framework of test project is 4.0.

推荐答案

我遇到了同样的问题。 Microsoft.SharePoint.dll似乎包含一些无法伪造的类...



我通过命令行运行fakes.exe让我的单元测试正常工作。存在一个命令行选项(/ tf),它允许我伪造我需要的类。



这是'我使用的命令:

C:\Program Files(x86)\ MSBuild\Microsoft \\ \\ VisualStudio \v11.0 \ Fakes \Fakes.exeC:\ Program Files \Common Files \ Mysoftoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll /tfv:4.5 / tf:SPList; SPWeb; SPSite
I ran into the same problem. The Microsoft.SharePoint.dll seems to contain some classes that cannot be faked...

I got my unit test working by running the fakes.exe from the command line. There exists a command line option (/tf) which allowed me to fake just the classes I needed.

Here''s the command I used:
"C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Fakes\Fakes.exe" "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll" /tfv:4.5 /tf:SPList;SPWeb;SPSite


这篇关于不能使用.net framework 4.5伪造sharepoint dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆