Click here to Skip to main content
11,644,286 members (72,407 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 23-Apr-13 23:36pm

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 570
1 jyo.net 484
2 Afzaal Ahmad Zeeshan 413
3 DamithSL 308
4 Sergey Alexandrovich Kryukov 276
0 OriginalGriff 795
1 DamithSL 611
2 Mika Wendelius 494
3 jyo.net 484
4 Afzaal Ahmad Zeeshan 404


Advertise | Privacy | Mobile
Web03 | 2.8.150731.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