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:
Mike Bierlee 2014-06-02 00:03:03 +02:00
parent a53080c109
commit 40e9ae4027

View file

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