In the implementation code "AsyncScopedLifestyle" is used but in the docs example it is not
// Setup Simple Injector
var container = new Container();
container.Register<IWorkerService, WorkerService>();
//this code should be added like in unit tests (set lifestyle for scoped registrations)
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
//and maybe even (default all registrations to scoped)
container.Options.DefaultLifestyle = new AsyncScopedLifestyle();
since the alternative would be to set .Register<...>(Lifestyle.Scoped) for all registrations. If this is not set they will default to transient.
Another point is to have at least one test to check .Dispose() is called. A typical scenario is to have a Entity framework DbContext registered and it should be disposed at the end of the scope.
In the implementation code "AsyncScopedLifestyle" is used but in the docs example it is not
//this code should be added like in unit tests (set lifestyle for scoped registrations) container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
//and maybe even (default all registrations to scoped) container.Options.DefaultLifestyle = new AsyncScopedLifestyle();
since the alternative would be to set .Register<...>(Lifestyle.Scoped) for all registrations. If this is not set they will default to transient.
Another point is to have at least one test to check .Dispose() is called. A typical scenario is to have a Entity framework DbContext registered and it should be disposed at the end of the scope.