Question

It's easy to add a Microsoft Fakes assembly to a test project: just right click on the parent assembly in the references section and choose "Add Fakes Assembly". However, when the parent assembly public interface changes (new interfaces, new methods), the Fakes Assembly becomes out of date.

When I right click on the parent assembly again, I'd love to see "Replace Fakes Assembly" or "Update Fakes Assembly", but all I see is "Add Fakes Assembly".

Choosing "Add Fakes Assembly" when the Fakes assembly has already been added results in an error:

Fakes assembly already referenced. A Fakes assembly for is already in the reference list. Remove the .Fakes reference and try again.

After following the instructions, then choosing "Add Fakes Assembly", the same error occurs.

I can resolve this by deleting the corresponding xml file in the Fakes directory (.fakes).

So, I have to manually delete two items (the fakes assembly and the fakes xml file) before I can successfully update the fakes assembly.

Is there an easier or more straightforward way to do this?

Was it helpful?

Solution

The Fakes code generator automatically detects changes in visible API of the target assembly and regenerates the fakes assembly when necessary. When the target assembly changes, simply build the test project that contains its .Fakes file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top