Skip to content

Commit

Permalink
added test case: "reset LazySingleton by instance only"
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjosch committed Dec 29, 2021
1 parent b646c2c commit 26576cd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/get_it_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,24 @@ void main() {
GetIt.I.reset();
});

test('reset LazySingleton by instance only', () {
// Arrange
final getIt = GetIt.instance;
constructorCounter = 0;
getIt.registerLazySingleton<TestClass>(() => TestClass());
final instance1 = getIt.get<TestClass>();

// Act
GetIt.I.resetLazySingleton(instance: instance1);

// Assert
final instance2 = getIt.get<TestClass>();
expect(instance1, isNot(instance2));
expect(constructorCounter, 2);

GetIt.I.reset();
});

test('unregister by instance when the dispose of the register is a future',
() async {
final getIt = GetIt.instance;
Expand Down

0 comments on commit 26576cd

Please sign in to comment.