Before asp.net 5 I would add "internalsVisibleTo(some.namespace.name)" to AssemblyInfo.cs - But I no longer have assemblyInfo.cs in my WebApi project.
How do I expose internals in a WebAPI project to my unitTest project?
Before asp.net 5 I would add "internalsVisibleTo(some.namespace.name)" to AssemblyInfo.cs - But I no longer have assemblyInfo.cs in my WebApi project.
How do I expose internals in a WebAPI project to my unitTest project?
You can add your own AssemblyInfo.cs file. Just add a class file, name it AssemblyInfo.cs (or any name for that matter), and replace all of its code with the following line:
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("some.assembly.name")]
You can see an example of the above answer in action in the asp open sourced MVC project available on github:
One of the best ways of figuring this stuff out is to get in there and have a dig about.
Good luck.
While creating an AssemblyInfo.cs
file is an option, I prefer to configure this in my project file.
Add this to your .csproj
file:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(AssemblyName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
© 2022 - 2024 — McMap. All rights reserved.