mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Move test descriptions outide of unittest block to make them readable when collapsed
This commit is contained in:
parent
464abd9cb0
commit
990c9f017b
|
@ -18,15 +18,15 @@ version(unittest) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test register concrete type
|
// Test register concrete type
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
auto registration = container.register!(TestClass)();
|
auto registration = container.register!(TestClass)();
|
||||||
assert(registration.registeredType == typeid(TestClass), "Type of registered type not the same");
|
assert(registration.registeredType == typeid(TestClass), "Type of registered type not the same");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test resolve registered type
|
// Test resolve registered type
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
container.register!(TestClass)();
|
container.register!(TestClass)();
|
||||||
TestClass actualInstance = container.resolve!(TestClass)();
|
TestClass actualInstance = container.resolve!(TestClass)();
|
||||||
|
@ -34,8 +34,8 @@ version(unittest) {
|
||||||
assert(cast(TestClass) actualInstance, "Resolved class is not the same type as expected");
|
assert(cast(TestClass) actualInstance, "Resolved class is not the same type as expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test register interface
|
// Test register interface
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
container.register!(TestInterface, TestClass)();
|
container.register!(TestInterface, TestClass)();
|
||||||
TestInterface actualInstance = container.resolve!(TestInterface)();
|
TestInterface actualInstance = container.resolve!(TestInterface)();
|
||||||
|
@ -43,48 +43,48 @@ version(unittest) {
|
||||||
assert(cast(TestInterface) actualInstance, "Resolved class is not the same type as expected");
|
assert(cast(TestInterface) actualInstance, "Resolved class is not the same type as expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test register unrelated types fails
|
// Test register unrelated types fails
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
assertThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(), "Registering unrelated types does not fail");
|
assertThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(), "Registering unrelated types does not fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test register unrelated types with disabled check on registration
|
// Test register unrelated types with disabled check on registration
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
assertNotThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(false), "Registering unrelated types while disabling type validity fails");
|
assertNotThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(false), "Registering unrelated types while disabling type validity fails");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test resolve non-registered type
|
// Test resolve non-registered type
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
assertThrown!ResolveException(container.resolve!(TestClass)(), "Resolving non-registered type does not fail");
|
assertThrown!ResolveException(container.resolve!(TestClass)(), "Resolving non-registered type does not fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test register unrelated class with disable global type validity disabled
|
// Test register unrelated class with disable global type validity disabled
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
container.typeValidityCheckEnabled = false;
|
container.typeValidityCheckEnabled = false;
|
||||||
assertNotThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(), "Registering unrelated types while disabling global type validity fails");
|
assertNotThrown!RegistrationException(container.register!(UnrelatedClass, TestClass)(), "Registering unrelated types while disabling global type validity fails");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test clear registrations
|
// Test clear registrations
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
container.register!(TestClass)();
|
container.register!(TestClass)();
|
||||||
container.clearRegistrations();
|
container.clearRegistrations();
|
||||||
assertThrown!ResolveException(container.resolve!(TestClass)(), "Resolving cleared type does not fail");
|
assertThrown!ResolveException(container.resolve!(TestClass)(), "Resolving cleared type does not fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test get singleton of container
|
// Test get singleton of container
|
||||||
|
unittest {
|
||||||
auto instance1 = Container.getInstance();
|
auto instance1 = Container.getInstance();
|
||||||
auto instance2 = Container.getInstance();
|
auto instance2 = Container.getInstance();
|
||||||
assert(instance1 is instance2, "getInstance does not return the same instance");
|
assert(instance1 is instance2, "getInstance does not return the same instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest {
|
|
||||||
// Test registering concrete type does not do a validity check
|
// Test registering concrete type does not do a validity check
|
||||||
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
assert(container.typeValidityCheckEnabled);
|
assert(container.typeValidityCheckEnabled);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue