diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 0e4273d..1e5a6d8 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -43,6 +43,21 @@ version(unittest) { public ComponentCat cat; } + class Eenie { + @Autowire + public Meenie meenie; + } + + class Meenie { + @Autowire + public Moe moe; + } + + class Moe { + @Autowire + public Eenie eenie; + } + // Test register concrete type unittest { auto container = new Container(); @@ -158,4 +173,16 @@ version(unittest) { assert(resolvedB.autowiredClass is existingA && resolvedA !is existingA, "Autowiring shouldn't rewire member when it is already wired to an instance"); } + + // Test autowiring circular dependency by third-degree + unittest { + auto container = new Container(); + container.register!Eenie; + container.register!Meenie; + container.register!Moe; + + auto eenie = container.resolve!Eenie; + + assert(eenie.meenie.moe.eenie is eenie, "Autowiring third-degree circular dependency failed"); + } } \ No newline at end of file