mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
implemented toFactory1 method
This commit is contained in:
@@ -61,8 +61,9 @@ class ResolvingContext<T> extends Resolver {
|
||||
* Создать фабричный resolver с 1 зависимостью от контейнера
|
||||
*/
|
||||
ResolvingContext<T> toFactory1<T1>(T Function(T1) factory) {
|
||||
// TODO: implement toFactory1
|
||||
throw UnimplementedError();
|
||||
Resolver<T> resolver =
|
||||
FactoryResolver<T>(() => factory(_container.resolve<T1>()));
|
||||
return toResolver(resolver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,15 @@ void main() {
|
||||
|
||||
expect(container.resolve<A>(), b);
|
||||
});
|
||||
|
||||
test("Bind to the factory resolves with value", () {
|
||||
final container = DiContainer();
|
||||
final b = B();
|
||||
container.bind<A>().toValue(b);
|
||||
container.bind<DependOnA>().toFactory1<A>((a) => DependOnA(a));
|
||||
|
||||
expect(container.resolve<DependOnA>().a, b);
|
||||
});
|
||||
}
|
||||
|
||||
ResolverMock<T> _makeResolver<T>(T expectedValue) {
|
||||
|
||||
Reference in New Issue
Block a user