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