I have 3 C# projects X, Y and Z. I have 2 unit test projects Xt that tests code in project X, and Yt that tests code in project Y. Project Z is a library project and is referenced by projects X and Y.
In both unit tests project I have generated a Fakes assembly for Z, meaning they both have their own version of Z.Fakes.dll. All DLLs are outputted into the same directory. Because they both create a Z.Fakes.dll, one overwrites the other in the output directory, depending on the build order, meaning one set of unit tests fails because the Shims & Stubs do no exist in the fakes assembly.
Assuming that I can't set different output directories for each unit test project, and cannot merge the unit tests into a single unit test project, how can I avoid this Fakes assembly name conflict? Is there any way to generate a Fakes Assembly and give it an alias e.g. Zx.Fakes.dll and Zy.Fakes.dll?
The way we are handling it is we have a separate Fakes project in the solution that you generate all of your fakes in, you then just add the dlls in the FakesAssemblies
folder in that fakes project. When you do that your solution reference structure should look like this
Solution - MyFakes - References - X - X.Fakes //Created via the right-click create Fake menu on X - Y - Y.Fakes //Created via the right-click create Fake menu on Y - Z - Z.Fakes //Created via the right-click create Fake menu on Z - X.csproj - References - Z - Xt.csproj - References - MyFakes //This is just for build order - X - ..\MyFakes\FakesAssemblies\X.Fakes.dll - Z - ..\MyFakes\FakesAssemblies\Z.Fakes.dll - Y.csproj - References - Z - Yt.csproj - References - MyFakes //This is just for build order - Y - ..\MyFakes\FakesAssemblies\Y.Fakes.dll - Z - ..\MyFakes\FakesAssemblies\Z.Fakes.dll - Z.csproj