I'm using the Microsoft Fakes testing framework. There's not much way around it as I need to use the shim/moles approach due to "legacy" code that I cannot change. It's code from a vendor with no source, it was written without testing in mind. So I'm stuck with 3 possible frameworks, TypeMock (expensive), Telerik's JustMock (expensive) or Microsoft's Fakes. As we already have VS Ultimate, we're opting for the fakes. As most people feel they need to suggest re-writing or modifying the code in some way to support using interfaces and/or dependency injection I'll tell you up front, this is not an option.
One of the issues I'm having is that the library I'm attempting to fake is huge and requires the use of the 64 bit version of fakes.exe and not the 32 bit (fakes.x86.exe), it runs into the memory limit of 32 bit apps.
The second issue is that I need to compile the fakes library using the v4.5 framework. It's possible through the command line, though undocumented. The reason is that in v4.5 they added the IReadOnly* interfaces in System.Collections.Generic and the library uses them. Compiling with v4, throws an error stating the types are not found, as expected.
The problem, Visual Studio is always using the x86 version and v4.0 framework and I can't find a way to override it. Does anybody know how to get it to use the 64 bit and v4.5 framework? My current idea is to not use visual studio's built-in stuff and just use the command line and manually reference the file. Then on every update of the dll, we would manually re-create it and update the reference. This file does not get updated very often so that is a possibility.
The command line I use to manually generate the fakes library (someone might find this useful) is:
"c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\fakes\fakes.exe" <assembly> /tfv:v4.5
The help command only shows that v2, v3.5 and v4 are possible options for tfv, but just for kicks I tried v4.5.
I have tried forcing the architecture on the app to x64 instead of any cpu, no change in which fakes.exe it ran. Looked in the .csproj file for the test, no change. Looked in the .csproj file that fakes.exe and it says to use v4 of the framework, opened in visual studio, changed to v4.5, compiled fine. Used the fakes command line, compiled fine. There is an attribute in the .fakes file in the project that allows the compiler version to be defined, but setting it to v4.5 still didn't work. I'm assuming that the version change in visual studio from v4 to v4.5 changed the assembly references as well. My next try is to try and change the template project if I can find it.
@schellack - Here's how I was able to "reference the created fakes dll and make sure the required references are in your test project"
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>Fakes\Microsoft.QualityTools.Testing.Fakes.dll</HintPath>
</Reference>
Now everything compiles and unit tests run
Can only think of the following (apologies if it is already set):
'Test' --> 'Test Settings' --> 'Default Processor Architecture' --> 'X64'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With