Autofac test all registered types can be resolved
autofac, c#
Solution
Autofac doesn't offer anything to that effect - because Autofac creates components in response to ResolveInstance, you're going to be faced with constructor side-effects etc.
Integration testing is the best way to address this.
Problem
I have a bunch of types registered with Autofac and some of the dependencies are rather deep. Is there a built in way to test that I can resolve all registered types? I want to fail fast at application startup, and not several minutes later part way in. This is what I'm currently doing, and it seems to work, but I still wonder if there isn't a better way. ``` public void VerifyAllRegistrations() { foreach (IComponentRegistration registration in _container.ComponentRegistrations) { bool isNewInstance; registration.ResolveInstance(_container, new Parameter[0], new Disposer(), out isNewInstance); } } private class Disposer : IDisposer { public void Dispose() { // no-op } public void AddInstanceForDisposal(IDisposable instance) { instance.Dispose(); } } ```