Lazy singleton tests
This commit is contained in:
parent
1958915d76
commit
ccdffe7901
1 changed files with 18 additions and 0 deletions
18
angel_container/test/lazy_test.dart
Normal file
18
angel_container/test/lazy_test.dart
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import 'package:angel_container/angel_container.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('returns the same instance', () {
|
||||||
|
var container = new Container(const EmptyReflector())
|
||||||
|
..registerLazySingleton<Dummy>((_) => new Dummy('a'));
|
||||||
|
|
||||||
|
var first = container.make<Dummy>();
|
||||||
|
expect(container.make<Dummy>(), first);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class Dummy {
|
||||||
|
final String s;
|
||||||
|
|
||||||
|
Dummy(this.s);
|
||||||
|
}
|
Loading…
Reference in a new issue