mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Skip validity check on registering concrete type
This commit is contained in:
parent
b18b6ed49c
commit
464abd9cb0
|
@ -40,7 +40,7 @@ class Container {
|
|||
}
|
||||
|
||||
public Registration register(ConcreteType)() {
|
||||
return register!(ConcreteType, ConcreteType)();
|
||||
return register!(ConcreteType, ConcreteType)(false);
|
||||
}
|
||||
|
||||
public Registration register(InterfaceType, ConcreteType)(bool checkTypeValidity = true) {
|
||||
|
|
|
@ -12,6 +12,12 @@ version(unittest) {
|
|||
class UnrelatedClass{
|
||||
}
|
||||
|
||||
class FailOnCreationClass {
|
||||
this() {
|
||||
throw new Exception("This class should not be instantiated");
|
||||
}
|
||||
}
|
||||
|
||||
unittest {
|
||||
// Test register concrete type
|
||||
auto container = new Container();
|
||||
|
@ -77,4 +83,15 @@ version(unittest) {
|
|||
assert(instance1 is instance2, "getInstance does not return the same instance");
|
||||
}
|
||||
|
||||
unittest {
|
||||
// Test registering concrete type does not do a validity check
|
||||
auto container = new Container();
|
||||
assert(container.typeValidityCheckEnabled);
|
||||
try {
|
||||
container.register!(FailOnCreationClass)();
|
||||
} catch (Exception) {
|
||||
assert(false, "Registering concrete type executed a validity check");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue