I have an internal class, with some internal methods that I would like to Shim using Microsoft Fakes. I have tried multiple things, came across this post, but nothing seems to work.
What I have so far:
internal class ClassToShim
{
internal IEnumerable<SomePublicType> Run(AnotherPublicType input1, AnInternalType input2)
{
//do something
}
}
Then, in the assemblyinfo of the same project:
[assembly: InternalsVisibleTo("<censored>.Fakes, PublicKey=<ourpublickey>")]
[assembly: InternalsVisibleTo("<censored>.UnitTests, PublicKey=<ourpublickey>")]
The fakes XML:
<ShimGeneration>
<Clear/>
<Add TypeName="ClassToShim!"/>
<!-- a bunch of public types where we have no issues -->
</ShimGeneration>
The problem is, that an empty Shim seems to be generated. In the test project I do have access to a Type named ShimClassToShim, but the AllInstances nested class is empty.
Opening up the generated Fakes assembly shows that there are shimmed methods, but they are internal to the fakes assembly!
Is there a way to have Fakes generate public Shim methods for internal classes, or inject an InternalsVisible assembly attribute into the generated fakes assembly?
Aucun commentaire:
Enregistrer un commentaire