From 40e9ae4027fea0d65c81d1cac8acee4653f10620 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Mon, 2 Jun 2014 00:03:03 +0200 Subject: [PATCH] Test circular dependency by third-degree Look I just had to made a term up for these kind of dependencies, okay? --- test/poodinis/containertest.d | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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