mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add unittest for fix in #37
This commit is contained in:
parent
00dd758e01
commit
0127c0a80c
|
@ -547,6 +547,20 @@ version (unittest)
|
||||||
assert(instance.red is container.resolve!Red);
|
assert(instance.red is container.resolve!Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test autowired, constructor injected class where constructor argument is templated
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
auto container = new shared DependencyContainer();
|
||||||
|
container.register!PieChart;
|
||||||
|
container.register!(TemplatedComponent!PieChart);
|
||||||
|
container.register!(ClassWithTemplatedConstructorArg!PieChart);
|
||||||
|
auto instance = container.resolve!(ClassWithTemplatedConstructorArg!PieChart);
|
||||||
|
|
||||||
|
assert(instance !is null);
|
||||||
|
assert(instance.dependency !is null);
|
||||||
|
assert(instance.dependency.instance !is null);
|
||||||
|
}
|
||||||
|
|
||||||
// Test injecting constructor with super-type parameter
|
// Test injecting constructor with super-type parameter
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
|
|
@ -779,4 +779,14 @@ version (unittest)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ClassWithTemplatedConstructorArg(T)
|
||||||
|
{
|
||||||
|
public TemplatedComponent!T dependency;
|
||||||
|
|
||||||
|
this(TemplatedComponent!T assignedDependency)
|
||||||
|
{
|
||||||
|
this.dependency = assignedDependency;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue