LCOV - code coverage report
Current view: top level - lib/data/repositories/map_pym - entreprise_repository_impl.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 15 53.3 %
Date: 2020-06-26 11:36:11 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:app_pym/core/network/network_info.dart';
       2             : import 'package:app_pym/data/datasources/map_pym_local_data_source.dart';
       3             : import 'package:app_pym/data/datasources/map_pym_remote_data_source.dart';
       4             : import 'package:app_pym/data/models/map_pym/entreprise_model.dart';
       5             : import 'package:app_pym/domain/entities/map_pym/entreprise.dart';
       6             : import 'package:app_pym/domain/repositories/map_pym/entreprise_repository.dart';
       7             : import 'package:connectivity/connectivity.dart';
       8             : import 'package:flutter/foundation.dart';
       9             : import 'package:injectable/injectable.dart';
      10             : 
      11             : @prod
      12             : @LazySingleton(as: EntrepriseRepository)
      13             : class EntrepriseRepositoryImpl implements EntrepriseRepository {
      14             :   final MapPymLocalDataSource localDataSource;
      15             :   final MapPymRemoteDataSource remoteDataSource;
      16             :   final NetworkInfo networkInfo;
      17             : 
      18           1 :   const EntrepriseRepositoryImpl({
      19             :     @required this.localDataSource,
      20             :     @required this.remoteDataSource,
      21             :     @required this.networkInfo,
      22             :   });
      23             : 
      24             :   @override
      25           1 :   Future<List<Entreprise>> fetchEntreprisesOfBatiment(int idBatiment) async {
      26           4 :     if (await networkInfo.result != ConnectivityResult.none) {
      27             :       final data =
      28           4 :           await remoteDataSource.fetchEntreprisesOfBatiment(idBatiment) ?? [];
      29           3 :       await localDataSource.cacheAllEntreprise(data);
      30           4 :       return data.map((e) => e?.toEntity()).toList();
      31             :     } else {
      32           2 :       final data = localDataSource.fetchEntreprisesOfBatiment(idBatiment) ?? [];
      33           4 :       return data.map((e) => e?.toEntity()).toList();
      34             :     }
      35             :   }
      36             : 
      37             :   @override
      38           0 :   Future<List<Entreprise>> fetchAll() async {
      39           0 :     if (await networkInfo.result != ConnectivityResult.none) {
      40           0 :       final data = await remoteDataSource.fetchAllEntreprises() ?? [];
      41           0 :       await localDataSource.cacheAllEntreprise(data);
      42           0 :       return data.map((e) => e?.toEntity()).toList();
      43             :     } else {
      44           0 :       final data = localDataSource.fetchAllEntreprises() ?? [];
      45           0 :       return data.map((e) => e?.toEntity()).toList();
      46             :     }
      47             :   }
      48             : }

Generated by: LCOV version 1.13