diff --git a/lib/src/data/network_manager.dart b/lib/src/data/network_manager.dart index f6740d4..946594e 100644 --- a/lib/src/data/network_manager.dart +++ b/lib/src/data/network_manager.dart @@ -2,9 +2,12 @@ import 'package:data_connection_checker/data_connection_checker.dart'; import '../domain/inetwork_manager.dart'; +///Implementation of NetworkManager class NetworkManager implements INetworkManager { + ///NetworkManager recive a connection Checker NetworkManager(this.connectionChecker); + /// Access to connectionChecker properties final DataConnectionChecker connectionChecker; @override diff --git a/lib/src/domain/inetwork_manager.dart b/lib/src/domain/inetwork_manager.dart index 45d3291..1ec9a05 100644 --- a/lib/src/domain/inetwork_manager.dart +++ b/lib/src/domain/inetwork_manager.dart @@ -1,3 +1,5 @@ +/// Interface for Network Manager abstract class INetworkManager { + /// Future that returns true if there is internet connection Future get isConnected; } diff --git a/pubspec.yaml b/pubspec.yaml index 17527b9..d41a81b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,18 +1,19 @@ name: network_manager description: Dart package which manages data connection. -version: 1.0.0 +version: 2.0.0 # homepage: https://www.example.com - environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: - data_connection_checker: ^0.3.4 + data_connection_checker: + git: + url: git://github.com/uSlashVlad/data_connection_checker.git equatable: ^2.0.0 - meta: ^1.1.8 - path: ^1.7.0 + meta: ^1.3.0 + path: ^1.8.0 dev_dependencies: - mockito: ^5.0.3 - test: ^1.14.4 + mocktail: ^0.1.1 + test: ^1.16.8 very_good_analysis: ^2.0.0 diff --git a/test/network_manager_test.dart b/test/network_manager_test.dart index 4c4c418..5c63eda 100644 --- a/test/network_manager_test.dart +++ b/test/network_manager_test.dart @@ -1,4 +1,4 @@ -import 'package:mockito/mockito.dart'; +import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; import 'package:network_manager/network_manager.dart'; @@ -6,8 +6,8 @@ import 'package:network_manager/network_manager.dart'; class MockDataConnectionChecker extends Mock implements DataConnectionChecker {} void main() { - NetworkManager networkInfo; - MockDataConnectionChecker dataConnectionChecker; + late NetworkManager networkInfo; + late MockDataConnectionChecker dataConnectionChecker; setUp(() { dataConnectionChecker = MockDataConnectionChecker(); @@ -22,14 +22,14 @@ void main() { final tIsConnected = Future.value(true); when( - dataConnectionChecker.hasConnection, + () => dataConnectionChecker.hasConnection, ).thenAnswer((_) => tIsConnected); // side effects -> collect the result to test final result = networkInfo.isConnected; // expectations -> compare result to expected value - verify(dataConnectionChecker.hasConnection); + verify(() => dataConnectionChecker.hasConnection); expect(result, tIsConnected); }, );