Avatar ·

Internal modifier in C# and unit testing: how to test internal methods?

Hello everyone! I'm a beginner C# developer, and I've encountered a problem with unit testing. In our project, there is a class with the `internal` modifier, and I can't access it from the test project. Here's an example: ```csharp // In the MyLibrary project (class library) internal class InternalService { internal string GetSecretData() { return "SensitiveInfo"; } } public class PublicService { private readonly InternalService _service = new InternalService(); public string ProcessData() { return _service.GetSecretData().ToUpper(); } } ``` I want to write a unit test for `InternalService.GetSecretData()`, but the test project (MyLibrary.Tests) cannot see this class. I've heard that you can use `InternalsVisibleTo`