From 1f0ff7ea88bdf6b31f4f6efb414500db0b9654c5 Mon Sep 17 00:00:00 2001 From: hmalik144 Date: Tue, 27 Sep 2022 21:48:09 +0100 Subject: [PATCH] Unit tests added --- test/unit_test/repository_test.mocks.dart | 341 ++++++++++++++++++++++ test/unit_test/viewmodel_test.mocks.dart | 117 ++++++++ 2 files changed, 458 insertions(+) create mode 100644 test/unit_test/repository_test.mocks.dart create mode 100644 test/unit_test/viewmodel_test.mocks.dart diff --git a/test/unit_test/repository_test.mocks.dart b/test/unit_test/repository_test.mocks.dart new file mode 100644 index 0000000..43a43b5 --- /dev/null +++ b/test/unit_test/repository_test.mocks.dart @@ -0,0 +1,341 @@ +// Mocks generated by Mockito 5.3.2 from annotations +// in easy_cc_flutter/test/unit_test/repository_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i8; + +import 'package:dio/dio.dart' as _i5; +import 'package:easy_cc_flutter/data/network/backupCurrencyApi.dart' as _i6; +import 'package:easy_cc_flutter/data/network/currencyApi.dart' as _i4; +import 'package:easy_cc_flutter/data/prefs/CurrencyPair.dart' as _i2; +import 'package:easy_cc_flutter/data/prefs/PreferenceProvider.dart' as _i7; +import 'package:mockito/mockito.dart' as _i1; +import 'package:retrofit/retrofit.dart' as _i3; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeCurrencyPair_0 extends _i1.SmartFake implements _i2.CurrencyPair { + _FakeCurrencyPair_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeHttpResponse_1 extends _i1.SmartFake + implements _i3.HttpResponse { + _FakeHttpResponse_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeResponseObject_2 extends _i1.SmartFake + implements _i4.ResponseObject { + _FakeResponseObject_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeResponse_3 extends _i1.SmartFake implements _i5.Response { + _FakeResponse_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCurrencyResponse_4 extends _i1.SmartFake + implements _i6.CurrencyResponse { + _FakeCurrencyResponse_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeRequestOptions_5 extends _i1.SmartFake + implements _i5.RequestOptions { + _FakeRequestOptions_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [PreferenceProvider]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockPreferenceProvider extends _i1.Mock + implements _i7.PreferenceProvider { + MockPreferenceProvider() { + _i1.throwOnMissingStub(this); + } + + @override + _i8.Future init() => (super.noSuchMethod( + Invocation.method( + #init, + [], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + @override + _i8.Future saveConversionPair( + String? s1, + String? s2, + ) => + (super.noSuchMethod( + Invocation.method( + #saveConversionPair, + [ + s1, + s2, + ], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + @override + _i2.CurrencyPair getConversionPair() => (super.noSuchMethod( + Invocation.method( + #getConversionPair, + [], + ), + returnValue: _FakeCurrencyPair_0( + this, + Invocation.method( + #getConversionPair, + [], + ), + ), + ) as _i2.CurrencyPair); +} + +/// A class which mocks [CurrencyApi]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockCurrencyApi extends _i1.Mock implements _i4.CurrencyApi { + MockCurrencyApi() { + _i1.throwOnMissingStub(this); + } + + @override + _i8.Future<_i3.HttpResponse<_i4.ResponseObject>> getConversion( + String? apiKey, + String? currency, + ) => + (super.noSuchMethod( + Invocation.method( + #getConversion, + [ + apiKey, + currency, + ], + ), + returnValue: _i8.Future<_i3.HttpResponse<_i4.ResponseObject>>.value( + _FakeHttpResponse_1<_i4.ResponseObject>( + this, + Invocation.method( + #getConversion, + [ + apiKey, + currency, + ], + ), + )), + ) as _i8.Future<_i3.HttpResponse<_i4.ResponseObject>>); +} + +/// A class which mocks [BackupCurrencyApi]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockBackupCurrencyApi extends _i1.Mock implements _i6.BackupCurrencyApi { + MockBackupCurrencyApi() { + _i1.throwOnMissingStub(this); + } + + @override + _i8.Future<_i3.HttpResponse<_i6.CurrencyResponse>> getCurrencyRate( + String? currencyFrom, + String? currencyTo, + ) => + (super.noSuchMethod( + Invocation.method( + #getCurrencyRate, + [ + currencyFrom, + currencyTo, + ], + ), + returnValue: _i8.Future<_i3.HttpResponse<_i6.CurrencyResponse>>.value( + _FakeHttpResponse_1<_i6.CurrencyResponse>( + this, + Invocation.method( + #getCurrencyRate, + [ + currencyFrom, + currencyTo, + ], + ), + )), + ) as _i8.Future<_i3.HttpResponse<_i6.CurrencyResponse>>); +} + +/// A class which mocks [HttpResponse]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockHttpResponse extends _i1.Mock + implements _i3.HttpResponse<_i4.ResponseObject> { + @override + _i4.ResponseObject get data => (super.noSuchMethod( + Invocation.getter(#data), + returnValue: _FakeResponseObject_2( + this, + Invocation.getter(#data), + ), + returnValueForMissingStub: _FakeResponseObject_2( + this, + Invocation.getter(#data), + ), + ) as _i4.ResponseObject); + @override + _i5.Response get response => (super.noSuchMethod( + Invocation.getter(#response), + returnValue: _FakeResponse_3( + this, + Invocation.getter(#response), + ), + returnValueForMissingStub: _FakeResponse_3( + this, + Invocation.getter(#response), + ), + ) as _i5.Response); +} + +/// A class which mocks [HttpResponse]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockCurrencyResponse extends _i1.Mock + implements _i3.HttpResponse<_i6.CurrencyResponse> { + @override + _i6.CurrencyResponse get data => (super.noSuchMethod( + Invocation.getter(#data), + returnValue: _FakeCurrencyResponse_4( + this, + Invocation.getter(#data), + ), + returnValueForMissingStub: _FakeCurrencyResponse_4( + this, + Invocation.getter(#data), + ), + ) as _i6.CurrencyResponse); + @override + _i5.Response get response => (super.noSuchMethod( + Invocation.getter(#response), + returnValue: _FakeResponse_3( + this, + Invocation.getter(#response), + ), + returnValueForMissingStub: _FakeResponse_3( + this, + Invocation.getter(#response), + ), + ) as _i5.Response); +} + +/// A class which mocks [DioError]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockDioError extends _i1.Mock implements _i5.DioError { + @override + _i5.RequestOptions get requestOptions => (super.noSuchMethod( + Invocation.getter(#requestOptions), + returnValue: _FakeRequestOptions_5( + this, + Invocation.getter(#requestOptions), + ), + returnValueForMissingStub: _FakeRequestOptions_5( + this, + Invocation.getter(#requestOptions), + ), + ) as _i5.RequestOptions); + @override + set requestOptions(_i5.RequestOptions? _requestOptions) => super.noSuchMethod( + Invocation.setter( + #requestOptions, + _requestOptions, + ), + returnValueForMissingStub: null, + ); + @override + set response(_i5.Response? _response) => super.noSuchMethod( + Invocation.setter( + #response, + _response, + ), + returnValueForMissingStub: null, + ); + @override + _i5.DioErrorType get type => (super.noSuchMethod( + Invocation.getter(#type), + returnValue: _i5.DioErrorType.connectTimeout, + returnValueForMissingStub: _i5.DioErrorType.connectTimeout, + ) as _i5.DioErrorType); + @override + set type(_i5.DioErrorType? _type) => super.noSuchMethod( + Invocation.setter( + #type, + _type, + ), + returnValueForMissingStub: null, + ); + @override + set error(dynamic _error) => super.noSuchMethod( + Invocation.setter( + #error, + _error, + ), + returnValueForMissingStub: null, + ); + @override + set stackTrace(StackTrace? stack) => super.noSuchMethod( + Invocation.setter( + #stackTrace, + stack, + ), + returnValueForMissingStub: null, + ); + @override + String get message => (super.noSuchMethod( + Invocation.getter(#message), + returnValue: '', + returnValueForMissingStub: '', + ) as String); +} diff --git a/test/unit_test/viewmodel_test.mocks.dart b/test/unit_test/viewmodel_test.mocks.dart new file mode 100644 index 0000000..57a0475 --- /dev/null +++ b/test/unit_test/viewmodel_test.mocks.dart @@ -0,0 +1,117 @@ +// Mocks generated by Mockito 5.3.2 from annotations +// in easy_cc_flutter/test/unit_test/viewmodel_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i5; + +import 'package:easy_cc_flutter/data/model/Currency.dart' as _i3; +import 'package:easy_cc_flutter/data/prefs/CurrencyPair.dart' as _i2; +import 'package:easy_cc_flutter/data/repository/RepositoryImpl.dart' as _i4; +import 'package:mockito/mockito.dart' as _i1; +import 'package:retrofit/retrofit.dart' as _i6; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeCurrencyPair_0 extends _i1.SmartFake implements _i2.CurrencyPair { + _FakeCurrencyPair_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeCurrency_1 extends _i1.SmartFake implements _i3.Currency { + _FakeCurrency_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [RepositoryImpl]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockRepositoryImpl extends _i1.Mock implements _i4.RepositoryImpl { + MockRepositoryImpl() { + _i1.throwOnMissingStub(this); + } + + @override + _i2.CurrencyPair getConversionPair() => (super.noSuchMethod( + Invocation.method( + #getConversionPair, + [], + ), + returnValue: _FakeCurrencyPair_0( + this, + Invocation.method( + #getConversionPair, + [], + ), + ), + ) as _i2.CurrencyPair); + @override + _i5.Future setConversionPair( + String? fromCurrency, + String? toCurrency, + ) => + (super.noSuchMethod( + Invocation.method( + #setConversionPair, + [ + fromCurrency, + toCurrency, + ], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future<_i3.Currency> getConversationRateFromApi( + String? fromCurrency, + String? toCurrency, + ) => + (super.noSuchMethod( + Invocation.method( + #getConversationRateFromApi, + [ + fromCurrency, + toCurrency, + ], + ), + returnValue: _i5.Future<_i3.Currency>.value(_FakeCurrency_1( + this, + Invocation.method( + #getConversationRateFromApi, + [ + fromCurrency, + toCurrency, + ], + ), + )), + ) as _i5.Future<_i3.Currency>); + @override + _i5.Future getDataFromApiCall( + _i5.Future<_i6.HttpResponse>? apiCall) => + (super.noSuchMethod( + Invocation.method( + #getDataFromApiCall, + [apiCall], + ), + returnValue: _i5.Future.value(null), + ) as _i5.Future); +}