From 09695e97702e3de0be2fe6044fbdb206dc99f519 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 28 Mar 2015 17:29:48 +0100 Subject: [PATCH] Add test for testing autowire stack pop-back mechanism --- test/poodinis/containertest.d | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index e75342d..5d921e9 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -100,6 +100,18 @@ version(unittest) { public Recursive recursive; } + class Moolah {} + + class Wants { + @Autowire + public Moolah moolah; + } + + class John { + @Autowire + public Wants wants; + } + // Test register concrete type unittest { shared(DependencyContainer) container = new DependencyContainer(); @@ -369,4 +381,17 @@ version(unittest) { 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."); } + + // Test autowire stack pop-back + unittest { + shared(DependencyContainer) container = new DependencyContainer(); + container.register!Moolah; + container.register!Wants.newInstance(); + container.register!John; + + container.resolve!Wants; + auto john = container.resolve!John; + + assert(john.wants.moolah !is null, "Autowire stack did not clear entries properly"); + } }