0

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?

2
  • 2
    Just ran out of close votes, so I'll leave this here for someone else: stackoverflow.com/questions/358196/… Commented Feb 25, 2016 at 17:13
  • 1
    If you truly need to test internal methods, and not just their public interfaces, then you can use the InternalsVisibleTo attribute. Commented Feb 25, 2016 at 17:14

2 Answers 2

9

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

[assembly:InternalsVisibleTo("YourTestAssembly")] 
Sign up to request clarification or add additional context in comments.

1 Comment

Just to be clear for others, this needs to be added to the \Properties\AssemblyInfo.cs file
1

You can use internalsvisibletoattribute. https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.