mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add test that asserts whether autowiring a class that depends on itself works.
This commit is contained in:
parent
89d82efb11
commit
83ad8c64c0
|
@ -95,6 +95,11 @@ version(unittest) {
|
||||||
public TestInterface testMember;
|
public TestInterface testMember;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Recursive {
|
||||||
|
@Autowire
|
||||||
|
public Recursive recursive;
|
||||||
|
}
|
||||||
|
|
||||||
// Test register concrete type
|
// Test register concrete type
|
||||||
unittest {
|
unittest {
|
||||||
auto container = new DependencyContainer();
|
auto container = new DependencyContainer();
|
||||||
|
@ -353,4 +358,15 @@ version(unittest) {
|
||||||
|
|
||||||
assert(firstRegistration is secondRegistration, "Registering the same registration by super type twice registers the dependencies twice.");
|
assert(firstRegistration is secondRegistration, "Registering the same registration by super type twice registers the dependencies twice.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve dependency depending on itself
|
||||||
|
unittest {
|
||||||
|
auto container = new DependencyContainer();
|
||||||
|
container.register!Recursive;
|
||||||
|
|
||||||
|
auto instance = container.resolve!Recursive;
|
||||||
|
|
||||||
|
assert(instance.recursive is instance, "Resolving dependency that depends on itself fails.");
|
||||||
|
assert(instance.recursive.recursive is instance, "Resolving dependency that depends on itself fails.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue