Search code examples
c#internalaccess-modifierstest-frameworktest-project

Is it possible for methods to have dual access modifiers?


I have many methods that are defined internal like so:

internal static string GetAJobShaNaNaNaShaNaNaNaNaNa(string Silhouettes)

However, in order to call them from a test project added to the solution, I need to change their access modifier from internal to public.

Is there a non-tedious way to make these methods public to the tests, yet remain internal otherwise?


Solution

  • Why not add InternalsVisibleTo in your assembly to allow the tests access?

    [assembly:InternalsVisibleTo("YourTestAssembly")]