Move some tests to proper location

This commit is contained in:
Mike Bierlee 2023-03-07 03:06:57 +03:00
parent 61db8f7572
commit 733c2aa236
2 changed files with 31 additions and 31 deletions

View file

@ -189,35 +189,4 @@ version (unittest) {
assert(instance.intValue == 8); assert(instance.intValue == 8);
assert(instance.unrelated !is null); assert(instance.unrelated !is null);
} }
// Test autowiring classes with recursive template parameters
unittest {
auto container = new shared DependencyContainer();
container.register!CircularTemplateComponentA;
container.register!CircularTemplateComponentB;
auto componentA = container.resolve!CircularTemplateComponentA;
auto componentB = container.resolve!CircularTemplateComponentB;
assert(componentA !is null);
assert(componentB !is null);
assert(componentA.instance is componentB);
assert(componentB.instance is componentA);
}
// Test autowiring class where a method is marked with @Autowire does nothing
unittest {
// It should also not show deprecation warning:
// Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `lala`
// the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from
auto container = new shared DependencyContainer();
container.register!AutowiredMethod;
auto instance = container.resolve!AutowiredMethod;
assert(instance !is null);
assert(instance.lala == 42);
assert(instance.lala(77) == 77);
}
} }

View file

@ -617,4 +617,35 @@ version (unittest) {
assert(instance !is null); assert(instance !is null);
} }
// Test autowiring classes with recursive template parameters
unittest {
auto container = new shared DependencyContainer();
container.register!CircularTemplateComponentA;
container.register!CircularTemplateComponentB;
auto componentA = container.resolve!CircularTemplateComponentA;
auto componentB = container.resolve!CircularTemplateComponentB;
assert(componentA !is null);
assert(componentB !is null);
assert(componentA.instance is componentB);
assert(componentB.instance is componentA);
}
// Test autowiring class where a method is marked with @Autowire does nothing
unittest {
// It should also not show deprecation warning:
// Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `lala`
// the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from
auto container = new shared DependencyContainer();
container.register!AutowiredMethod;
auto instance = container.resolve!AutowiredMethod;
assert(instance !is null);
assert(instance.lala == 42);
assert(instance.lala(77) == 77);
}
} }