diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 8c7b966..0881782 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -95,6 +95,11 @@ version(unittest) { public TestInterface testMember; } + class Recursive { + @Autowire + public Recursive recursive; + } + // Test register concrete type unittest { auto container = new DependencyContainer(); @@ -353,4 +358,15 @@ version(unittest) { assert(firstRegistration is secondRegistration, "Registering the same registration by super type twice registers the dependencies twice."); } + + // Resolve dependency depending on itself + unittest { + auto container = new DependencyContainer(); + container.register!Recursive; + + auto instance = container.resolve!Recursive; + + assert(instance.recursive is instance, "Resolving dependency that depends on itself fails."); + assert(instance.recursive.recursive is instance, "Resolving dependency that depends on itself fails."); + } }