How do I allow assembly (unit testing one) to access internal properties of another assembly?

后端 未结 5 1696
说谎
说谎 2020-12-04 09:51

I would like my Core assembly to not expose a certain class and I would still like to be able to test it. How can I do that ?

5条回答
  •  囚心锁ツ
    2020-12-04 10:21

    With InternalsVisible if your assemblies are strongly named you need to specify the public key (note: the full key not the public key token) for example...

    [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("BoardEx_BusinessObjects.Tests, 
      PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb3a2d8 etc etc")]
    

    and the following trick is really useful for getting the public key without resorting to the cmd line...

    http://www.andrewconnell.com/blog/archive/2006/09/15/4587.aspx

提交回复
热议问题