mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add test for autowiring circular dependencies
This commit is contained in:
parent
f4ad79003e
commit
60b1149aea
|
@ -26,6 +26,16 @@ version(unittest) {
|
|||
public AutowiredClass autowiredClass;
|
||||
}
|
||||
|
||||
class ComponentCat {
|
||||
@Autowire
|
||||
public ComponentMouse mouse;
|
||||
}
|
||||
|
||||
class ComponentMouse {
|
||||
@Autowire
|
||||
public ComponentMouse cat;
|
||||
}
|
||||
|
||||
// Test register concrete type
|
||||
unittest {
|
||||
auto container = new Container();
|
||||
|
@ -138,5 +148,14 @@ version(unittest) {
|
|||
auto autowiredInstance = container.resolve!AutowiredClass;
|
||||
assert(componentInstance.autowiredClass is autowiredInstance, "Member is not autowired upon resolving");
|
||||
}
|
||||
|
||||
|
||||
// Test circular autowiring
|
||||
unittest {
|
||||
auto container = new Container();
|
||||
container.register!ComponentMouse;
|
||||
container.register!ComponentCat;
|
||||
auto mouse = container.resolve!ComponentMouse;
|
||||
auto cat = container.resolve!ComponentCat;
|
||||
assert(mouse.cat is cat && cat.mouse is mouse, "Circular dependencies should be autowirable");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue