Please provide a method like ValidateConfiguration() for tests
See original GitHub issueThere’s nothing in the documentation about validating a container. I want a guarantee under test that for all the dependencies the container knows about, you would not receive a configuration error.
This is the best thing I can find, courtesy of @mikehadlow:
private static void CheckForPotentiallyMisconfiguredComponents(IWindsorContainer container)
{
var host = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();
var handlers = diagnostics.Inspect();
if (handlers.Any())
{
var message = new StringBuilder();
var inspector = new DependencyInspector(message);
foreach (IExposeDependencyInfo handler in handlers)
{
handler.ObtainDependencyDetails(inspector);
}
throw new MisconfiguredComponentException(message.ToString());
}
}
There’s nothing obvious about this code. If it is indeed the code you’re recommend, please ship the code as a ValidateConfiguration()
.
I’m surprised that such a test isn’t recommended practice for every user. This is something I’d expect to find conspicuously linked from both the readme and the FAQ. This is the closest thing I could find. It talks about testing various aspects of certain registrations but does not mention validating registrations to check specifically that all dependencies can be satisfied: https://github.com/castleproject/Windsor/blob/master/docs/mvc-tutorial-part-3a-testing-your-first-installer.md
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:51 (30 by maintainers)
Top GitHub Comments
Ha ha, no worries! I have baked your code in and can see the 3 failing tests. Going to sign off for tonight and pick this up first thing tomorrow.
Absolutely, that sounds good. I’m catching up on my backlog, so don’t let me hold you back.