I want to unit test a class with internal
protection level in an ASP.NET Core project. I have added an AssemblyInfo.cs file to the properties of the project under test:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo("xxx.xxx.xxxTests")]
However when I call this in my test:
mockApplicationBuilder.Verify(y => y.UseMiddleware<HttpExceptionMiddleware>());
I still get
HttpExceptionMiddleware is inaccessible due to its protection level
Why is my AssemblyInfo attribute not working?
My setup is that I have a solution with 2 folders (src, and tests) and those folders have the src project and the test project in root of the folder respectively. The AssemblyInfo.cs file is in my properties of my src project. Do I need to specify a full path to the test project in my assemblyInfo.cs attribute?
There is an AssemblyInfo.cs
in my test project too, although I think that is irrelevant.
Without getting to poke around in your solution I can only offer suggestions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With