mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add test for testing autowire stack pop-back mechanism
This commit is contained in:
parent
a7ab3ea4d8
commit
09695e9770
|
@ -100,6 +100,18 @@ version(unittest) {
|
||||||
public Recursive recursive;
|
public Recursive recursive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Moolah {}
|
||||||
|
|
||||||
|
class Wants {
|
||||||
|
@Autowire
|
||||||
|
public Moolah moolah;
|
||||||
|
}
|
||||||
|
|
||||||
|
class John {
|
||||||
|
@Autowire
|
||||||
|
public Wants wants;
|
||||||
|
}
|
||||||
|
|
||||||
// Test register concrete type
|
// Test register concrete type
|
||||||
unittest {
|
unittest {
|
||||||
shared(DependencyContainer) container = new DependencyContainer();
|
shared(DependencyContainer) container = new DependencyContainer();
|
||||||
|
@ -369,4 +381,17 @@ version(unittest) {
|
||||||
assert(instance.recursive is instance, "Resolving dependency that depends on itself fails.");
|
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.");
|
assert(instance.recursive.recursive is instance, "Resolving dependency that depends on itself fails.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test autowire stack pop-back
|
||||||
|
unittest {
|
||||||
|
shared(DependencyContainer) container = new DependencyContainer();
|
||||||
|
container.register!Moolah;
|
||||||
|
container.register!Wants.newInstance();
|
||||||
|
container.register!John;
|
||||||
|
|
||||||
|
container.resolve!Wants;
|
||||||
|
auto john = container.resolve!John;
|
||||||
|
|
||||||
|
assert(john.wants.moolah !is null, "Autowire stack did not clear entries properly");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue