Mocking internal types
Depending on your project requirements, you might need to create mock objects for internal types. Internal types or members in C# are accessible only within files in the same assembly. Mocking internal types can be done by adding custom attributes to the AssemblyInfo.cs file of the concerned projects.
If the assembly containing the internal types does not already have the AssemblyInfo.cs file, you can add it. Also, when the assembly is not strongly-named, you can add the InternalsVisibleTo attribute, which has the public key excluded. You have to specify the name of the project to share visibility with, which in this case should be the test project.
If you change the LoanService access modifier to internal, you will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access