Add test for testing autowire stack pop-back mechanism

This commit is contained in:
Mike Bierlee 2015-03-28 17:29:48 +01:00
parent a7ab3ea4d8
commit 09695e9770

View file

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