Add test of prevention of transitive dependencies

This commit is contained in:
Mike Bierlee 2016-09-03 18:40:01 +02:00
parent 67fa51a14f
commit 9cc320aa93

View file

@ -207,6 +207,18 @@ version(unittest) {
this(Pot pot) {} this(Pot pot) {}
} }
class Rock {
this(Scissors scissors) {}
}
class Paper {
this(Rock rock) {}
}
class Scissors {
this(Paper paper) {}
}
// Test register concrete type // Test register concrete type
unittest { unittest {
auto container = new shared DependencyContainer(); auto container = new shared DependencyContainer();
@ -712,4 +724,14 @@ version(unittest) {
assertThrown!InstanceCreationException(container.resolve!Pot); assertThrown!InstanceCreationException(container.resolve!Pot);
} }
// Test prevention of transitive circular dependencies during constructor injection
unittest {
auto container = new shared DependencyContainer();
container.register!Rock;
container.register!Paper;
container.register!Scissors;
assertThrown!InstanceCreationException(container.resolve!Rock);
}
} }