Idea: Make it possible to unit test a custom IActiveHealthCheckPolicy
What should we add or change to make your life better?
I've implemented a custom IActiveHealthCheckPolicy. I've started trying to write some unit tests for this policy, but it seems to be very difficult because ClusterInfo is sealed and only has an internal constructor. I don't think just un-sealing or making the constructor public would solve my problem, because it looks like I'm going to keep running into the same problem - constructing a ClusterInfo requires an IDestinationManager - which is also internal, as is its only implementation.
Why is this important to you?
I'd like to be able to test my code. I'm happy to do the work to make a PR to make things more testable, but I would appreciate some guidance on the best way to achieve that goal.
This would be great as right now it is not possible to build a custom health check policy using TDD. Looking at the unit tests in the project they have access to the internal classes. For anyone else to extend YARP this is needed.
Yes, we should do something about this.
Linking the code for reference: https://github.com/microsoft/reverse-proxy/blob/66f39b675e05c9b2490cf49f817c33060c9b02e8/src/ReverseProxy/Service/HealthChecks/IActiveHealthCheckPolicy.cs#L26 https://github.com/microsoft/reverse-proxy/blob/66f39b675e05c9b2490cf49f817c33060c9b02e8/src/ReverseProxy/Service/RuntimeModel/ClusterInfo.cs#L29 Today ClusterInfo is created by ClusterManager which is also internal.
Triage: Yes, we should address it as part of API review. And fish for more. Unit testing is important.