How to test internal / protected
methods in c#
The internal keyword is an access modifier for types and type members. Internal types
or members are accessible only within files in the same assembly
The protected keyword is a member access modifier. A protected member is
accessible within its class and by derived class instances.
How to test internal methods?
Specifies that types that are ordinarily visible only within the current assembly are
visible to a specified assembly.
• When used as a declaration modifier, the new keyword explicitly hides a
member that is inherited from a base class.
• When you hide an inherited member, the derived version of the member
replaces the base class version.
• Although you can hide members without using the new modifier, you get a
compiler warning. If you use new to explicitly hide a member, it suppresses
How to test protected methods?
– better solution!
Set method modifier to protected internal, and use InternalsVisibleToAttribute
• protected internal: Access is limited to the current assembly or types derived
from the containing class.
• How to Test Private and Protected methods in .NET
• InternalsVisibleToAttribute Class
• new Modifier
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.