Force Pex To Find Factories In Satellite Pex Assemblies

I am still at my client Pexing out. It’s really neat to explore this whole new framework but honestly I am starting to get a little bored writing nothing but tests, even though Pex makes it a little better.

One problem I ran into when building the tests for my client was Pex was barfing because could not a factory that was located in a satellite Pex assembly. The only way that I could seemingly get it to work was to use to copy the relevant class to the other main Pex assembly, but this is terribly because not having the ambiguous references is pretty bad.

This is fixable however through the use of the assembly level PexExplorableFromFactoriesFromType and PexExplorableFromFactoriesFromAssembly attributes which allow you to specify factory methods to use in a declarative fashion.

This looks like the following:

[assembly: PexExplorableFromFactoriesFromType(typeof(TypeWithFactoryMethod))]

Addition of the above will allow the mining of the appropriate factory methods.