Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900