.NET has a elaborate visibility model -- types, methods, fields, ... can be private, public, internal, etc.
When Pex generates tests, Pex will only attempt to perform actions (calling constructors, methods, setting fields,etc.) which are legal regarding .NET visibility rules from within the context of the generated tests
. (Interestingly, this context depends on Pex' test output configuration
The rules are as follows:
- Visibility of internal members: Pex assumes that the generated tests will have access to internal members that were visible to the enclosing PexClass; .NET has the InternalsVisibleToAttribute to extend the visibility of internal members to other assemblies.
- Visibility of private and family (protected in C#) members of the PexClass:
- Pex always places the generated tests either directly in the PexClass or into a subclass. Thus, Pex assumes that it may use all family visible members (protected in C#).
- If the generated tests are placed directly into the PexClass (usually by using partial classes), Pex assumes that it may use all private members of the PexClass as well.
- Visibility of public members: Of course, Pex assumes that it may use all exported members visible in the context of the PexClass.