Click here to Skip to main content
11,413,548 members (71,317 online)
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 404
1 Sascha Lefévre 200
2 Maciej Los 185
3 ProgramFOX 130
4 Sergey Alexandrovich Kryukov 110
0 Sergey Alexandrovich Kryukov 9,035
1 OriginalGriff 7,387
2 Maciej Los 3,640
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web02 | 2.8.150427.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
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