mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Test circular dependency by third-degree
Look I just had to made a term up for these kind of dependencies, okay?
This commit is contained in:
parent
a53080c109
commit
40e9ae4027
|
@ -43,6 +43,21 @@ version(unittest) {
|
||||||
public ComponentCat cat;
|
public ComponentCat cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Eenie {
|
||||||
|
@Autowire
|
||||||
|
public Meenie meenie;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meenie {
|
||||||
|
@Autowire
|
||||||
|
public Moe moe;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Moe {
|
||||||
|
@Autowire
|
||||||
|
public Eenie eenie;
|
||||||
|
}
|
||||||
|
|
||||||
// Test register concrete type
|
// Test register concrete type
|
||||||
unittest {
|
unittest {
|
||||||
auto container = new Container();
|
auto container = new Container();
|
||||||
|
@ -158,4 +173,16 @@ version(unittest) {
|
||||||
|
|
||||||
assert(resolvedB.autowiredClass is existingA && resolvedA !is existingA, "Autowiring shouldn't rewire member when it is already wired to an instance");
|
assert(resolvedB.autowiredClass is existingA && resolvedA !is existingA, "Autowiring shouldn't rewire member when it is already wired to an instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test autowiring circular dependency by third-degree
|
||||||
|
unittest {
|
||||||
|
auto container = new Container();
|
||||||
|
container.register!Eenie;
|
||||||
|
container.register!Meenie;
|
||||||
|
container.register!Moe;
|
||||||
|
|
||||||
|
auto eenie = container.resolve!Eenie;
|
||||||
|
|
||||||
|
assert(eenie.meenie.moe.eenie is eenie, "Autowiring third-degree circular dependency failed");
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue