Making internal methods and properties visible in tests gives a finer level granularity of tests hopefully making them less coupled and more cohesive as well as more focused on what they are testing. This is without making the API visible to the outside.
In the older days, we used add into the 'Assembly.cs'
1 |
[assembly: InternalsVisibleTo("MyAssembly.Tests")] |
But you can also add the line into csproj
1 2 3 4 5 |
<ItemGroup> <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> <_Parameter1>$(AssemblyName).Tests</_Parameter1> </AssemblyAttribute> </ItemGroup> |