I'm registering many types to my Container
, implementing all sorts of interfaces.
In some programmatic manner, I want to have a unit test that will check all resolving are successful, meaning there are no circular or missing dependencies in the registrations.
I tried to add something like this:
[TestMethod]
public void Resolve_CanResolveAllTypes()
{
foreach (var registration in _container.ComponentRegistry.Registrations)
{
var instance = _container.Resolve(registration.Activator.LimitType);
Assert.IsNotNull(instance);
}
}
But it fails on first run on resolving Autofac.Core.Lifetime.LifetimeScope
, though I have methods that accepts ILifetimeScope
as parameter and get it just fine when my application starts.