BoDi icon indicating copy to clipboard operation
BoDi copied to clipboard

IsRegistered<T> fails for registrations on parent containers

Open Cylox opened this issue 7 years ago • 1 comments

I'm using a SpecFlow runtime plugin and the RegisterGlobalDependencies event to add my own dependencies to the global SpecFlow container. When I ask a sub-container (Feature- or ScenarioContainer) inside the test execution whether the dependency is registered through the IsRegistered<T> call it returns always false. This is because IsRegistered<T> only looks at the registrations of the current container, not the base container. Now the weird thing is that you can successfully call Resolve<T> with the same interface and get the dependency. This is because Resolve<T> will ask the base container for resolving the type if it cannot resolve the type itself whereas IsRegistered<T> will not consult the base container. This should be fixed by making IsRegistered<T> also check the base container registrations.

Cylox avatar Aug 20 '18 13:08 Cylox

Pull request https://github.com/gasparnagy/BoDi/pull/20 includes a fix for your issue.

patrickdreyer avatar Dec 06 '18 00:12 patrickdreyer