Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Sharepoint
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 24-Apr-13 0:36am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100