Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InternalsVisibleTo does not work

I insert the line:

[assembly: InternalsVisibleTo("MyTests")]

inside my project under test( Properties/AssemblyInfo.cs) where MyTests is the name of the Unit Test project. But for some reason I still cannot access the internal methods from the unit test project.

Any ideas about what I am doing wrong ?

like image 756
Cemre Mengü Avatar asked Sep 17 '13 09:09

Cemre Mengü


People also ask

What is InternalsVisibleTo in c#?

It allows you to access classes, methods and properties only within files in the same assembly. But sometimes you need to have info about the internal state of that class but within a different assembly.


1 Answers

If your assembly is signed with a strong name look at this answer.

Otherwise check that the name of your test assembly really is "MyTests.dll" (it doesn't have to match the project name, though it will by default).

like image 104
Joe Avatar answered Oct 12 '22 15:10

Joe