使用简单的注入器作为自动模拟与 AutoFixture

Using Simple Injector as Auto-Mocking with AutoFixture

是否可以附加 ResolveUnregisteredType 方法来尝试使用 AutoFixture 已注册类型解析任何未注册类型?

类似于

Container.ResolveUnregisteredType += (sender, e) => {
    e.Register(new SpecimenContext(fixture).Resolve(type));
}

你快到了:

Container.ResolveUnregisteredType += (sender, e) =>
{
    var instance = new SpecimenContext(fixture).Resolve(e.UnregisteredServiceType);
    e.Register(() => instance);
}