mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Fix incorrect clearing of registrations
This commit is contained in:
parent
eb203c8e3c
commit
e19564e3cf
|
@ -67,7 +67,7 @@ class Container {
|
|||
}
|
||||
|
||||
public void clearAllRegistrations() {
|
||||
registrations.clear();
|
||||
registrations = null;
|
||||
}
|
||||
|
||||
public void removeRegistration(RegistrationType)() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue