Skip to content

Commit

Permalink
added new generic type test
Browse files Browse the repository at this point in the history
  • Loading branch information
escamoteur committed Jul 14, 2021
1 parent 1563e23 commit b646c2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ packages:
path: ".."
relative: true
source: path
version: "7.1.3"
version: "7.2.0"
glob:
dependency: transitive
description:
Expand Down
31 changes: 8 additions & 23 deletions test/get_it_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ int constructorCounter = 0;
int disposeCounter = 0;
int errorCounter = 0;

class TestBaseClassGeneric<T> {
late Type t;
TestBaseClassGeneric() {
t = T;
}
}
class TestBaseClassGeneric<T> {}

class TestClassGeneric<T> implements TestBaseClassGeneric<T> {
late Type t;
}
class TestClassGeneric<T> implements TestBaseClassGeneric<T> {}

abstract class TestBaseClass {}

Expand Down Expand Up @@ -795,22 +788,14 @@ void main() {

expect(instance1 is TestClass, true);
});
// test('GenericType test', () {
// GetIt.I.registerSingleton<TestBaseClassGeneric<TestBaseClass>>(
// TestBaseClassGeneric<TestBaseClass>());
test('GenericType test', () {
GetIt.I.registerSingleton<TestBaseClassGeneric<TestBaseClass>>(
TestClassGeneric<TestBaseClass>());

// final instance1 = GetIt.I.get<TestClassGeneric<TestBaseClass>>();
// expect(instance1 is TestClassGeneric<TestBaseClass>, true);
// });
// test('GenericType test2', () {
// var x = TestBaseClassGeneric<TestBaseClassGeneric<TestBaseClass>>();
// var y = TestBaseClassGeneric<TestBaseClassGeneric<TestBaseClass>>();
final instance1 = GetIt.I.get<TestBaseClassGeneric<TestBaseClass>>();

// Map<Type, String> testMap = {TestBaseClassGeneric: 'TestEntry'};

// final instance1 = GetIt.I.get<TestClassGeneric<TestBaseClass>>();
// expect(instance1 is TestClassGeneric<TestBaseClass>, true);
// });
expect(instance1 is TestClassGeneric<TestBaseClass>, true);
});

test('register LazySingleton with lambda and factory function', () {
GetIt.I.registerLazySingleton(() => SingletonInjector.configuration());
Expand Down

0 comments on commit b646c2c

Please sign in to comment.