Add test for autowiring member with different attribute

This commit is contained in:
Mike Bierlee 2014-05-30 01:04:40 +02:00
parent 58d0c2b6e0
commit ec5cad2bbf

View file

@ -28,6 +28,13 @@ version(unittest) {
} }
} }
class DummyAttribute{};
class ComponentE {
@DummyAttribute
public ComponentC componentC;
}
// Test autowiring concrete type to existing instance // Test autowiring concrete type to existing instance
unittest { unittest {
auto container = new Container(); auto container = new Container();
@ -64,4 +71,12 @@ version(unittest) {
ComponentD componentD = new ComponentD(); ComponentD componentD = new ComponentD();
assertThrown!(ResolveException)(container.autowire!(ComponentD)(componentD), "Autowiring unregistered type should throw ResolveException"); assertThrown!(ResolveException)(container.autowire!(ComponentD)(componentD), "Autowiring unregistered type should throw ResolveException");
} }
// Test autowiring member with non-autowire attribute does not autowire
unittest {
auto container = new Container();
ComponentE componentE = new ComponentE();
container.autowire!ComponentE(componentE);
assert(componentE.componentC is null, "Autowiring should not occur for members with attributes other than @Autowire");
}
} }