From e19564e3cf68853c1a64298f70f30d13cd9d8463 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sun, 5 Oct 2014 13:43:57 +0200 Subject: [PATCH] Fix incorrect clearing of registrations --- source/poodinis/container.d | 2 +- test/poodinis/containertest.d | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 0fc4bce..e8ae80b 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -67,7 +67,7 @@ class Container { } public void clearAllRegistrations() { - registrations.clear(); + registrations = null; } public void removeRegistration(RegistrationType)() { diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index f49180d..c526bf3 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -243,4 +243,18 @@ version(unittest) { assert(superInstance.banana is null, "Autowire instance which was resolved by interface type, which was not expected to be possible"); } + + // Test reusing a container after clearing all registrations + unittest { + auto container = new Container(); + container.register!Banana; + container.clearAllRegistrations(); + try { + container.resolve!Banana; + } catch (ResolveException e) { + container.register!Banana; + return; + } + assert(false); + } } \ No newline at end of file