Fix incorrect clearing of registrations

This commit is contained in:
Mike Bierlee 2014-10-05 13:43:57 +02:00
parent eb203c8e3c
commit e19564e3cf
2 changed files with 15 additions and 1 deletions

View file

@ -67,7 +67,7 @@ class Container {
}
public void clearAllRegistrations() {
registrations.clear();
registrations = null;
}
public void removeRegistration(RegistrationType)() {

View file

@ -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);
}
}