@@ -7,16 +7,16 @@ import 'package:ForDev/domain/helpers/helpers.dart';
77import 'package:ForDev/data/usecases/usecases.dart' ;
88import 'package:ForDev/main/composites/composites.dart' ;
99
10- class RemoteLoadSurveyResultSpy extends Mock implements RemoteLoadSurveyResult {}
1110class LocalLoadSurveyResultSpy extends Mock implements LocalLoadSurveyResult {}
11+ class RemoteLoadSurveyResultSpy extends Mock implements RemoteLoadSurveyResult {}
1212
1313void main () {
1414RemoteLoadSurveyResultWithLocalFallback sut;
1515RemoteLoadSurveyResultSpy remote;
1616LocalLoadSurveyResultSpy local;
1717String surveyId;
18- SurveyResultEntity remoteResult ;
19- SurveyResultEntity localResult ;
18+ SurveyResultEntity remoteSurveyResult ;
19+ SurveyResultEntity localSurveyResult ;
2020
2121SurveyResultEntity mockSurveyResult ()=> SurveyResultEntity (
2222 surveyId: faker.guid.guid (),
@@ -28,23 +28,23 @@ void main() {
2828 )]
2929 );
3030
31- PostExpectation mockRemoteLoadCall ()=> when (remote.loadBySurvey (surveyId: anyNamed ('surveyId' )));
31+ PostExpectation mockRemoteLoadBySurveyCall ()=> when (remote.loadBySurvey (surveyId: anyNamed ('surveyId' )));
3232
33- void mockRemoteLoad () {
34- remoteResult = mockSurveyResult ();
35- mockRemoteLoadCall ().thenAnswer ((_)async => remoteResult );
33+ void mockRemoteLoadBySurvey () {
34+ remoteSurveyResult = mockSurveyResult ();
35+ mockRemoteLoadBySurveyCall ().thenAnswer ((_)async => remoteSurveyResult );
3636 }
3737
38- void mockRemoteLoadError (DomainError error)=> mockRemoteLoadCall ().thenThrow (error);
38+ void mockRemoteLoadBySurveyError (DomainError error)=> mockRemoteLoadBySurveyCall ().thenThrow (error);
3939
40- PostExpectation mockLocalLoadCall ()=> when (local.loadBySurvey (surveyId: anyNamed ('surveyId' )));
40+ PostExpectation mockLocalLoadBySurveyCall ()=> when (local.loadBySurvey (surveyId: anyNamed ('surveyId' )));
4141
42- void mockLocalLoad () {
43- localResult = mockSurveyResult ();
44- mockLocalLoadCall ().thenAnswer ((_)async => localResult );
42+ void mockLocalLoadBySurvey () {
43+ localSurveyResult = mockSurveyResult ();
44+ mockLocalLoadBySurveyCall ().thenAnswer ((_)async => localSurveyResult );
4545 }
4646
47- void mockLocalLoadError ()=> mockLocalLoadCall ().thenThrow (DomainError .unexpected);
47+ void mockLocalLoadBySurveyError ()=> mockLocalLoadBySurveyCall ().thenThrow (DomainError .unexpected);
4848
4949setUp (() {
5050 surveyId= faker.guid.guid ();
@@ -54,11 +54,11 @@ void main() {
5454 remote: remote,
5555 local: local
5656 );
57- mockRemoteLoad ();
58- mockLocalLoad ();
57+ mockRemoteLoadBySurvey ();
58+ mockLocalLoadBySurvey ();
5959 });
6060
61- test ('Should call remoteLoadBySurvey ' , ()async {
61+ test ('Should call remoteloadBySurvey ' , ()async {
6262await sut.loadBySurvey (surveyId: surveyId);
6363
6464verify (remote.loadBySurvey (surveyId: surveyId)).called (1 );
@@ -67,43 +67,43 @@ void main() {
6767test ('Should call local save with remote data' , ()async {
6868await sut.loadBySurvey (surveyId: surveyId);
6969
70- verify (local.save (surveyId: surveyId, surveyResult: remoteResult )).called (1 );
70+ verify (local.save (surveyId: surveyId, surveyResult: remoteSurveyResult )).called (1 );
7171 });
7272
73- test ('Should return remotedata ' , ()async {
73+ test ('Should return remotesurveyResult ' , ()async {
7474final response= await sut.loadBySurvey (surveyId: surveyId);
7575
76- expect (response,remoteResult );
76+ expect (response,remoteSurveyResult );
7777 });
7878
79- test ('Should rethrow if remoteLoadBySurvey throws AccessDeniedError' , ()async {
80- mockRemoteLoadError (DomainError .accessDenied);
79+ test ('Should rethrow if remoteloadBySurvey throws AccessDeniedError' , ()async {
80+ mockRemoteLoadBySurveyError (DomainError .accessDenied);
8181
8282final future= sut.loadBySurvey (surveyId: surveyId);
8383
8484expect (future,throwsA (DomainError .accessDenied));
8585 });
8686
87- test ('Should call localLoadBySurvey on remote error' , ()async {
88- mockRemoteLoadError (DomainError .unexpected);
87+ test ('Should call localloadBySurvey on remote error' , ()async {
88+ mockRemoteLoadBySurveyError (DomainError .unexpected);
8989
9090await sut.loadBySurvey (surveyId: surveyId);
9191
9292verify (local.validate (surveyId)).called (1 );
9393verify (local.loadBySurvey (surveyId: surveyId)).called (1 );
9494 });
9595
96- test ('Should return localdata ' , ()async {
97- mockRemoteLoadError (DomainError .unexpected);
96+ test ('Should return localsurveyResult ' , ()async {
97+ mockRemoteLoadBySurveyError (DomainError .unexpected);
9898
9999final response= await sut.loadBySurvey (surveyId: surveyId);
100100
101- expect (response,localResult );
101+ expect (response,localSurveyResult );
102102 });
103103
104- test ('Should throwUnexpedError if localload fails ' , ()async {
105- mockRemoteLoadError (DomainError .unexpected);
106- mockLocalLoadError ();
104+ test ('Should throwUnexpectedError ifremote and localloadBySurvey throws ' , ()async {
105+ mockRemoteLoadBySurveyError (DomainError .unexpected);
106+ mockLocalLoadBySurveyError ();
107107
108108final future= sut.loadBySurvey (surveyId: surveyId);
109109