From 60b1149aeac44f6c26e275e1c26daed1c64eecc2 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Fri, 30 May 2014 01:19:51 +0200 Subject: [PATCH] Add test for autowiring circular dependencies --- test/poodinis/containertest.d | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index eed57d2..b5292a8 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -26,6 +26,16 @@ version(unittest) { public AutowiredClass autowiredClass; } + class ComponentCat { + @Autowire + public ComponentMouse mouse; + } + + class ComponentMouse { + @Autowire + public ComponentMouse cat; + } + // Test register concrete type unittest { auto container = new Container(); @@ -138,5 +148,14 @@ version(unittest) { auto autowiredInstance = container.resolve!AutowiredClass; assert(componentInstance.autowiredClass is autowiredInstance, "Member is not autowired upon resolving"); } - + + // Test circular autowiring + unittest { + auto container = new Container(); + container.register!ComponentMouse; + container.register!ComponentCat; + auto mouse = container.resolve!ComponentMouse; + auto cat = container.resolve!ComponentCat; + assert(mouse.cat is cat && cat.mouse is mouse, "Circular dependencies should be autowirable"); + } } \ No newline at end of file