2

I'v a problem with Fakes Framework and internal class. I've just readed and used the advice here: How to mock/isolate internal classes in VS 2012 with Fakes Framework shims?

but, I still not see internal classes.

I've this solution: ACQTool (class library project) ACQTool.UnitTests (test project)

in ACQTool namespace there is ACQTool.Utils internal class.

in ACQTool/AssemblyInfo.cs I've added these lines:

[assembly: InternalsVisibleTo("ACQTool.UnitTests, PublicKey=57ad8399-13fd-4d4d-90fd-c521c2164d25")]
[assembly: InternalsVisibleTo("ACQTool.Fakes, PublicKey=0024..47bc")]
[assembly: InternalsVisibleTo("Microsoft.QualityTools.Testing.Fakes, PublicKey=0024..47bc")]

After build, I can use ACQTool.Utils in test class, but not exist ACQTool.Fakes.ShimUtils/StubUtils. Help me please.

Community
  • 1
  • 1
Glauco Cucchiar
  • 764
  • 5
  • 19

2 Answers2

0

Probably You should paste Public key generated by sn.exe tool. Usually it stored somewhere like:

"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sn.exe"

call it from command line:

sn.exe -p SomeName.snk SomeName.PublicKey
sn.exe -tp SomeName.PublicKey

and paste the output to the "InternalsVisibleTo" Public key param.

Important note from that msdn page that I missed: The Fakes framework uses the same key to sign all generated assemblies, so the public key if signing should ALWAYS be PublicKey=0024000004800000940000000602000000240000525341310004000001000100e92de‌​cb949446f688ab9f6973436c535bf50acd1fd580495aae3f875aa4e4f663ca77908c63b7f0996977c‌​b98fcfdb35e05aa2c842002703cad835473caac5ef14107e3a7fae01120a96558785f48319f66daab‌​c862872b2c53f5ac11fa335c0165e202b4c011334c7bc8f4c4e570cf255190f4e3e2cbc9137ca57cb‌​687947bc

gabba
  • 2,815
  • 2
  • 27
  • 48
0

It's kinda weird I just replicated your problem and surely it wasn't generating the internals in Fake assembly at first. I followed below steps and it started working even for other namespaces too:

  • Add a public class under the namespace Utils.
  • Rebuild the Test project and the internal will start showing up.
  • Remove that public class and rebuild again.

I removed everything from Utils namespace and added new internal class and it is working fine since then. It's just a workaround to generate namespace that contains internals.

vendettamit
  • 14,315
  • 2
  • 32
  • 54
  • My Namespace is "ACQTool". I've a "Utils.cs" class with: internal class Utils, public enum LogSeveriry, public class DisabledEvents, public static class ExExtensions. I can see all casses except Utils – Glauco Cucchiar Feb 17 '16 at 11:11