diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 7ed61fa..d9fc746 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -372,6 +372,7 @@ synchronized class DependencyContainer { public void registerContext(Context : ApplicationContext)() { auto context = new Context(); context.registerDependencies(this); + context.registerContextComponents(this); } /** diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index da32df9..4c47098 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -15,6 +15,11 @@ version(unittest) { public override void registerDependencies(shared(DependencyContainer) container) { container.register!TestClass; } + + @Component + public UnrelatedClass unrelated() { + return new UnrelatedClass(); + } } interface TestInterface { @@ -500,4 +505,13 @@ version(unittest) { assert(instance !is null); } + + // Test resolving dependency from registered application context + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.registerContext!TestContext; + auto instance = container.resolve!UnrelatedClass; + + assert(instance !is null); + } }