Mocking Extension Methods

Daniel Cazzulino had a very helpful post about how to mock extension methods. The only part I don’t like about this method is the fact you have to make internals visible to the test assembly using an assembly directive:

[assembly: InternalsVisibleTo("Project.Test")]

This is not really bad, since test projects are not deployed. One possible issue with it is assemblies renaming, but that doesn’t happen very often and also relatively easy to track down once things break.

Thanks to Daniel.

No Comments