From 4833c4ca28f45f24efa5f58655600df055fb6e42 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 3 Sep 2022 10:30:19 -0600 Subject: [PATCH] couple more tests --- test/hive/db_test.dart | 69 +++++ ...timated_rate_exchange_form_state_test.dart | 215 +++++++++++++ ...d_rate_exchange_form_state_test.mocks.dart | 212 +++++++++++++ test/models/isar/log_test.dart | 15 + .../exchange/exchange_view_test.mocks.dart | 287 ++++++++++++++---- 5 files changed, 746 insertions(+), 52 deletions(-) create mode 100644 test/hive/db_test.dart create mode 100644 test/models/exchange/estimated_rate_exchange_form_state_test.dart create mode 100644 test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart create mode 100644 test/models/isar/log_test.dart diff --git a/test/hive/db_test.dart b/test/hive/db_test.dart new file mode 100644 index 000000000..a87f568bd --- /dev/null +++ b/test/hive/db_test.dart @@ -0,0 +1,69 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:hive_test/hive_test.dart'; +import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +void main() { + group("DB box names", () { + test("address book", () => expect(DB.boxNameAddressBook, "addressBook")); + test("debug info", () => expect(DB.boxNameDebugInfo, "debugInfoBox")); + test("nodes", () => expect(DB.boxNameNodeModels, "nodeModels")); + test("primary nodes", () => expect(DB.boxNamePrimaryNodes, "primaryNodes")); + test("wallets info", () => expect(DB.boxNameAllWalletsData, "wallets")); + test("notifications", + () => expect(DB.boxNameNotifications, "notificationModels")); + test( + "watched transactions", + () => expect( + DB.boxNameWatchedTransactions, "watchedTxNotificationModels")); + test( + "watched trades", + () => + expect(DB.boxNameWatchedTrades, "watchedTradesNotificationModels")); + test("trades", () => expect(DB.boxNameTrades, "exchangeTransactionsBox")); + test("trade notes", () => expect(DB.boxNameTradeNotes, "tradeNotesBox")); + test("tx <> trade lookup table", + () => expect(DB.boxNameTradeLookup, "tradeToTxidLookUpBox")); + test("favorite wallets", + () => expect(DB.boxNameFavoriteWallets, "favoriteWallets")); + test("preferences", () => expect(DB.boxNamePrefs, "prefs")); + test( + "deleted wallets to clear out on start", + () => + expect(DB.boxNameWalletsToDeleteOnStart, "walletsToDeleteOnStart")); + test("price cache", + () => expect(DB.boxNamePriceCache, "priceAPIPrice24hCache")); + + test("boxNameTxCache", () { + for (final coin in Coin.values) { + expect(DB.instance.boxNameTxCache(coin: coin), "${coin.name}_txCache"); + } + }); + + test("boxNameSetCache", () { + for (final coin in Coin.values) { + expect(DB.instance.boxNameSetCache(coin: coin), + "${coin.name}_anonymitySetCache"); + } + }); + + test("boxNameUsedSerialsCache", () { + for (final coin in Coin.values) { + expect(DB.instance.boxNameUsedSerialsCache(coin: coin), + "${coin.name}_usedSerialsCache"); + } + }); + }); + + group("tests requiring test hive environment", () { + setUp(() async { + await setUpTestHive(); + }); + + test("DB init", () async {}); + + tearDown(() async { + await tearDownTestHive(); + }); + }); +} diff --git a/test/models/exchange/estimated_rate_exchange_form_state_test.dart b/test/models/exchange/estimated_rate_exchange_form_state_test.dart new file mode 100644 index 000000000..3c6c869e5 --- /dev/null +++ b/test/models/exchange/estimated_rate_exchange_form_state_test.dart @@ -0,0 +1,215 @@ +import 'package:decimal/decimal.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:stackwallet/models/exchange/change_now/change_now_response.dart'; +import 'package:stackwallet/models/exchange/change_now/currency.dart'; +import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart'; +import 'package:stackwallet/models/exchange/estimated_rate_exchange_form_state.dart'; +import 'package:stackwallet/services/change_now/change_now.dart'; + +import 'estimated_rate_exchange_form_state_test.mocks.dart'; + +@GenerateMocks([ChangeNow]) +void main() { + final currencyA = Currency( + ticker: "btc", + name: "Bitcoin", + image: "image.url", + hasExternalId: false, + isFiat: false, + featured: false, + isStable: true, + supportsFixedRate: true, + ); + final currencyB = Currency( + ticker: "xmr", + name: "Monero", + image: "image.url", + hasExternalId: false, + isFiat: false, + featured: false, + isStable: true, + supportsFixedRate: true, + ); + final currencyC = Currency( + ticker: "firo", + name: "Firo", + image: "image.url", + hasExternalId: false, + isFiat: false, + featured: false, + isStable: true, + supportsFixedRate: true, + ); + + test("EstimatedRateExchangeFormState constructor", () async { + final state = EstimatedRateExchangeFormState(); + + expect(state.from, null); + expect(state.to, null); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, ""); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, ""); + }); + + test("init EstimatedRateExchangeFormState", () async { + final state = EstimatedRateExchangeFormState(); + + await state.init(currencyA, currencyB); + + expect(state.from, currencyA); + expect(state.to, currencyB); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, ""); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, ""); + }); + + test("updateTo on fresh state", () async { + final state = EstimatedRateExchangeFormState(); + + await state.updateTo(currencyA, false); + + expect(state.from, null); + expect(state.to, currencyA); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, ""); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, ""); + }); + + test( + "updateTo after updateFrom where amounts are null and getMinimalExchangeAmount succeeds", + () async { + final cn = MockChangeNow(); + + final state = EstimatedRateExchangeFormState(); + state.cnTesting = cn; + + when(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .thenAnswer((_) async => ChangeNowResponse(value: Decimal.fromInt(42))); + + await state.updateFrom(currencyA, true); + await state.updateTo(currencyB, true); + + expect(state.from, currencyA); + expect(state.to, currencyB); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, ""); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, ""); + + verify(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .called(1); + }); + + test( + "updateTo after updateFrom where amounts are null and getMinimalExchangeAmount fails", + () async { + final cn = MockChangeNow(); + + final state = EstimatedRateExchangeFormState(); + state.cnTesting = cn; + + when(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .thenAnswer((_) async => ChangeNowResponse()); + + await state.updateFrom(currencyA, true); + await state.updateTo(currencyB, true); + + expect(state.from, currencyA); + expect(state.to, currencyB); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, ""); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, ""); + + verify(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .called(1); + }); + + test( + "updateTo after updateFrom and setFromAmountAndCalculateToAmount where fromAmount is less than the minimum required exchange amount", + () async { + final cn = MockChangeNow(); + + final state = EstimatedRateExchangeFormState(); + state.cnTesting = cn; + + when(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .thenAnswer((_) async => ChangeNowResponse(value: Decimal.fromInt(42))); + + await state.updateFrom(currencyA, true); + await state.setFromAmountAndCalculateToAmount(Decimal.parse("10.10"), true); + await state.updateTo(currencyB, true); + + expect(state.from, currencyA); + expect(state.to, currencyB); + expect(state.canExchange, false); + expect(state.rate, null); + expect(state.rateDisplayString, "N/A"); + expect(state.fromAmountString, "10.10000000"); + expect(state.toAmountString, ""); + expect(state.minimumSendWarning, "Minimum amount 42 BTC"); + + verify(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .called(1); + }); + + test( + "updateTo after updateFrom and setFromAmountAndCalculateToAmount where fromAmount is greater than the minimum required exchange amount", + () async { + final cn = MockChangeNow(); + + final state = EstimatedRateExchangeFormState(); + state.cnTesting = cn; + + when(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .thenAnswer((_) async => ChangeNowResponse(value: Decimal.fromInt(42))); + when(cn.getEstimatedExchangeAmount( + fromTicker: "btc", + toTicker: "xmr", + fromAmount: Decimal.parse("110.10"))) + .thenAnswer((_) async => ChangeNowResponse( + value: EstimatedExchangeAmount( + transactionSpeedForecast: '10-60', + rateId: 'some rate id', + warningMessage: '', + estimatedAmount: Decimal.parse("302.002348"), + ))); + + await state.updateFrom(currencyA, true); + await state.setFromAmountAndCalculateToAmount( + Decimal.parse("110.10"), true); + await state.updateTo(currencyB, true); + + expect(state.from, currencyA); + expect(state.to, currencyB); + expect(state.canExchange, true); + expect(state.rate, Decimal.parse("2.742982270663")); + expect(state.rateDisplayString, "1 BTC ~2.74298227 XMR"); + expect(state.fromAmountString, "110.10000000"); + expect(state.toAmountString, "302.00234800"); + expect(state.minimumSendWarning, ""); + + verify(cn.getMinimalExchangeAmount(fromTicker: "btc", toTicker: "xmr")) + .called(1); + verify(cn.getEstimatedExchangeAmount( + fromTicker: "btc", + toTicker: "xmr", + fromAmount: Decimal.parse("110.10"))) + .called(1); + }); +} diff --git a/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart b/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart new file mode 100644 index 000000000..27aa1a772 --- /dev/null +++ b/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart @@ -0,0 +1,212 @@ +// Mocks generated by Mockito 5.2.0 from annotations +// in stackwallet/test/models/exchange/estimated_rate_exchange_form_state_test.dart. +// Do not manually edit this file. + +import 'dart:async' as _i5; + +import 'package:decimal/decimal.dart' as _i7; +import 'package:http/http.dart' as _i4; +import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/exchange/change_now/available_floating_rate_pair.dart' + as _i12; +import 'package:stackwallet/models/exchange/change_now/change_now_response.dart' + as _i2; +import 'package:stackwallet/models/exchange/change_now/currency.dart' as _i6; +import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart' + as _i8; +import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart' + as _i10; +import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart' + as _i11; +import 'package:stackwallet/models/exchange/change_now/fixed_rate_market.dart' + as _i9; +import 'package:stackwallet/services/change_now/change_now.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 + +class _FakeChangeNowResponse_0 extends _i1.Fake + implements _i2.ChangeNowResponse {} + +/// A class which mocks [ChangeNow]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockChangeNow extends _i1.Mock implements _i3.ChangeNow { + MockChangeNow() { + _i1.throwOnMissingStub(this); + } + + @override + set client(_i4.Client? _client) => + super.noSuchMethod(Invocation.setter(#client, _client), + returnValueForMissingStub: null); + @override + _i5.Future<_i2.ChangeNowResponse>> getAvailableCurrencies( + {bool? fixedRate, bool? active}) => + (super.noSuchMethod( + Invocation.method(#getAvailableCurrencies, [], + {#fixedRate: fixedRate, #active: active}), + returnValue: Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); + @override + _i5.Future<_i2.ChangeNowResponse>> getPairedCurrencies( + {String? ticker, bool? fixedRate}) => + (super.noSuchMethod( + Invocation.method(#getPairedCurrencies, [], + {#ticker: ticker, #fixedRate: fixedRate}), + returnValue: Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i7.Decimal>> getMinimalExchangeAmount( + {String? fromTicker, String? toTicker, String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getMinimalExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #apiKey: apiKey + }), + returnValue: Future<_i2.ChangeNowResponse<_i7.Decimal>>.value( + _FakeChangeNowResponse_0<_i7.Decimal>())) + as _i5.Future<_i2.ChangeNowResponse<_i7.Decimal>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>> + getEstimatedExchangeAmount( + {String? fromTicker, + String? toTicker, + _i7.Decimal? fromAmount, + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getEstimatedExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #fromAmount: fromAmount, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse< + _i8.EstimatedExchangeAmount>>.value( + _FakeChangeNowResponse_0<_i8.EstimatedExchangeAmount>())) + as _i5 + .Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>> + getEstimatedFixedRateExchangeAmount( + {String? fromTicker, + String? toTicker, + _i7.Decimal? fromAmount, + bool? useRateId = true, + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getEstimatedFixedRateExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #fromAmount: fromAmount, + #useRateId: useRateId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse< + _i8.EstimatedExchangeAmount>>.value( + _FakeChangeNowResponse_0<_i8.EstimatedExchangeAmount>())) + as _i5 + .Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>>); + @override + _i5.Future<_i2.ChangeNowResponse>> + getAvailableFixedRateMarkets({String? apiKey}) => (super.noSuchMethod( + Invocation.method( + #getAvailableFixedRateMarkets, [], {#apiKey: apiKey}), + returnValue: + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + createStandardExchangeTransaction( + {String? fromTicker, + String? toTicker, + String? receivingAddress, + _i7.Decimal? amount, + String? extraId = r'', + String? userId = r'', + String? contactEmail = r'', + String? refundAddress = r'', + String? refundExtraId = r'', + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#createStandardExchangeTransaction, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #receivingAddress: receivingAddress, + #amount: amount, + #extraId: extraId, + #userId: userId, + #contactEmail: contactEmail, + #refundAddress: refundAddress, + #refundExtraId: refundExtraId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i5 + .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + createFixedRateExchangeTransaction( + {String? fromTicker, + String? toTicker, + String? receivingAddress, + _i7.Decimal? amount, + String? rateId, + String? extraId = r'', + String? userId = r'', + String? contactEmail = r'', + String? refundAddress = r'', + String? refundExtraId = r'', + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#createFixedRateExchangeTransaction, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #receivingAddress: receivingAddress, + #amount: amount, + #rateId: rateId, + #extraId: extraId, + #userId: userId, + #contactEmail: contactEmail, + #refundAddress: refundAddress, + #refundExtraId: refundExtraId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i5 + .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + @override + _i5.Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>> + getTransactionStatus({String? id, String? apiKey}) => (super.noSuchMethod( + Invocation.method( + #getTransactionStatus, [], {#id: id, #apiKey: apiKey}), + returnValue: + Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>>.value( + _FakeChangeNowResponse_0<_i11.ExchangeTransactionStatus>())) as _i5 + .Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>>); + @override + _i5.Future<_i2.ChangeNowResponse>> + getAvailableFloatingRatePairs({bool? includePartners = false}) => (super + .noSuchMethod( + Invocation.method(#getAvailableFloatingRatePairs, [], + {#includePartners: includePartners}), + returnValue: + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); +} diff --git a/test/models/isar/log_test.dart b/test/models/isar/log_test.dart new file mode 100644 index 000000000..15e1e245b --- /dev/null +++ b/test/models/isar/log_test.dart @@ -0,0 +1,15 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:stackwallet/models/isar/models/log.dart'; +import 'package:stackwallet/utilities/logger.dart'; + +void main() { + test("Log class", () { + final log = Log() + ..message = "hello" + ..timestampInMillisUTC = 100000001 + ..logLevel = LogLevel.Fatal; + + expect(log.toString(), "[Fatal][1970-01-02 03:46:40.001Z]: hello"); + expect(log.id, -9223372036854775808); + }); +} diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index f659e3104..aa517d09b 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -2,20 +2,33 @@ // in stackwallet/test/screen_tests/exchange/exchange_view_test.dart. // Do not manually edit this file. -import 'dart:async' as _i6; -import 'dart:ui' as _i7; +import 'dart:async' as _i7; +import 'dart:ui' as _i8; +import 'package:decimal/decimal.dart' as _i15; +import 'package:http/http.dart' as _i13; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/exchange/change_now/available_floating_rate_pair.dart' + as _i19; +import 'package:stackwallet/models/exchange/change_now/change_now_response.dart' + as _i2; +import 'package:stackwallet/models/exchange/change_now/currency.dart' as _i14; +import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart' + as _i16; import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart' - as _i9; + as _i10; +import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart' + as _i18; +import 'package:stackwallet/models/exchange/change_now/fixed_rate_market.dart' + as _i17; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' - as _i4; -import 'package:stackwallet/services/change_now/change_now.dart' as _i11; -import 'package:stackwallet/services/trade_notes_service.dart' as _i10; -import 'package:stackwallet/services/trade_service.dart' as _i8; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i5; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i3; -import 'package:stackwallet/utilities/prefs.dart' as _i2; + as _i5; +import 'package:stackwallet/services/change_now/change_now.dart' as _i12; +import 'package:stackwallet/services/trade_notes_service.dart' as _i11; +import 'package:stackwallet/services/trade_service.dart' as _i9; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i6; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i4; +import 'package:stackwallet/utilities/prefs.dart' as _i3; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -27,10 +40,13 @@ import 'package:stackwallet/utilities/prefs.dart' as _i2; // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +class _FakeChangeNowResponse_0 extends _i1.Fake + implements _i2.ChangeNowResponse {} + /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i2.Prefs { +class MockPrefs extends _i1.Mock implements _i3.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -69,11 +85,11 @@ class MockPrefs extends _i1.Mock implements _i2.Prefs { Invocation.setter(#walletIdsSyncOnStartup, walletIdsSyncOnStartup), returnValueForMissingStub: null); @override - _i3.SyncingType get syncType => + _i4.SyncingType get syncType => (super.noSuchMethod(Invocation.getter(#syncType), - returnValue: _i3.SyncingType.currentWalletOnly) as _i3.SyncingType); + returnValue: _i4.SyncingType.currentWalletOnly) as _i4.SyncingType); @override - set syncType(_i3.SyncingType? syncType) => + set syncType(_i4.SyncingType? syncType) => super.noSuchMethod(Invocation.setter(#syncType, syncType), returnValueForMissingStub: null); @override @@ -109,11 +125,11 @@ class MockPrefs extends _i1.Mock implements _i2.Prefs { super.noSuchMethod(Invocation.setter(#currency, newCurrency), returnValueForMissingStub: null); @override - _i4.ExchangeRateType get exchangeRateType => + _i5.ExchangeRateType get exchangeRateType => (super.noSuchMethod(Invocation.getter(#exchangeRateType), - returnValue: _i4.ExchangeRateType.estimated) as _i4.ExchangeRateType); + returnValue: _i5.ExchangeRateType.estimated) as _i5.ExchangeRateType); @override - set exchangeRateType(_i4.ExchangeRateType? exchangeRateType) => + set exchangeRateType(_i5.ExchangeRateType? exchangeRateType) => super.noSuchMethod(Invocation.setter(#exchangeRateType, exchangeRateType), returnValueForMissingStub: null); @override @@ -153,12 +169,12 @@ class MockPrefs extends _i1.Mock implements _i2.Prefs { Invocation.setter(#autoBackupLocation, autoBackupLocation), returnValueForMissingStub: null); @override - _i5.BackupFrequencyType get backupFrequencyType => + _i6.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod(Invocation.getter(#backupFrequencyType), - returnValue: _i5.BackupFrequencyType.everyTenMinutes) - as _i5.BackupFrequencyType); + returnValue: _i6.BackupFrequencyType.everyTenMinutes) + as _i6.BackupFrequencyType); @override - set backupFrequencyType(_i5.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i6.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter(#backupFrequencyType, backupFrequencyType), returnValueForMissingStub: null); @@ -171,20 +187,20 @@ class MockPrefs extends _i1.Mock implements _i2.Prefs { (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i6.Future init() => (super.noSuchMethod(Invocation.method(#init, []), + _i7.Future init() => (super.noSuchMethod(Invocation.method(#init, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i6.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i7.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method(#incrementCurrentNotificationIndex, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - void addListener(_i7.VoidCallback? listener) => + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override - void removeListener(_i7.VoidCallback? listener) => + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override @@ -199,57 +215,57 @@ class MockPrefs extends _i1.Mock implements _i2.Prefs { /// A class which mocks [TradesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTradesService extends _i1.Mock implements _i8.TradesService { +class MockTradesService extends _i1.Mock implements _i9.TradesService { MockTradesService() { _i1.throwOnMissingStub(this); } @override - List<_i9.ExchangeTransaction> get trades => + List<_i10.ExchangeTransaction> get trades => (super.noSuchMethod(Invocation.getter(#trades), - returnValue: <_i9.ExchangeTransaction>[]) - as List<_i9.ExchangeTransaction>); + returnValue: <_i10.ExchangeTransaction>[]) + as List<_i10.ExchangeTransaction>); @override bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @override - _i6.Future add( - {_i9.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => + _i7.Future add( + {_i10.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => (super.noSuchMethod( Invocation.method(#add, [], {#trade: trade, #shouldNotifyListeners: shouldNotifyListeners}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i6.Future edit( - {_i9.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => + _i7.Future edit( + {_i10.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => (super.noSuchMethod( Invocation.method(#edit, [], {#trade: trade, #shouldNotifyListeners: shouldNotifyListeners}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i6.Future delete( - {_i9.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => + _i7.Future delete( + {_i10.ExchangeTransaction? trade, bool? shouldNotifyListeners}) => (super.noSuchMethod( Invocation.method(#delete, [], {#trade: trade, #shouldNotifyListeners: shouldNotifyListeners}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i6.Future deleteByUuid({String? uuid, bool? shouldNotifyListeners}) => + _i7.Future deleteByUuid({String? uuid, bool? shouldNotifyListeners}) => (super.noSuchMethod( Invocation.method(#deleteByUuid, [], {#uuid: uuid, #shouldNotifyListeners: shouldNotifyListeners}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - void addListener(_i7.VoidCallback? listener) => + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override - void removeListener(_i7.VoidCallback? listener) => + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override @@ -264,7 +280,7 @@ class MockTradesService extends _i1.Mock implements _i8.TradesService { /// A class which mocks [TradeNotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTradeNotesService extends _i1.Mock implements _i10.TradeNotesService { +class MockTradeNotesService extends _i1.Mock implements _i11.TradeNotesService { MockTradeNotesService() { _i1.throwOnMissingStub(this); } @@ -281,21 +297,21 @@ class MockTradeNotesService extends _i1.Mock implements _i10.TradeNotesService { (super.noSuchMethod(Invocation.method(#getNote, [], {#tradeId: tradeId}), returnValue: '') as String); @override - _i6.Future set({String? tradeId, String? note}) => (super.noSuchMethod( + _i7.Future set({String? tradeId, String? note}) => (super.noSuchMethod( Invocation.method(#set, [], {#tradeId: tradeId, #note: note}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - _i6.Future delete({String? tradeId}) => + _i7.Future delete({String? tradeId}) => (super.noSuchMethod(Invocation.method(#delete, [], {#tradeId: tradeId}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + returnValueForMissingStub: Future.value()) as _i7.Future); @override - void addListener(_i7.VoidCallback? listener) => + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); @override - void removeListener(_i7.VoidCallback? listener) => + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#removeListener, [listener]), returnValueForMissingStub: null); @override @@ -310,8 +326,175 @@ class MockTradeNotesService extends _i1.Mock implements _i10.TradeNotesService { /// A class which mocks [ChangeNow]. /// /// See the documentation for Mockito's code generation for more information. -class MockChangeNow extends _i1.Mock implements _i11.ChangeNow { +class MockChangeNow extends _i1.Mock implements _i12.ChangeNow { MockChangeNow() { _i1.throwOnMissingStub(this); } + + @override + set client(_i13.Client? _client) => + super.noSuchMethod(Invocation.setter(#client, _client), + returnValueForMissingStub: null); + @override + _i7.Future<_i2.ChangeNowResponse>> getAvailableCurrencies( + {bool? fixedRate, bool? active}) => + (super.noSuchMethod( + Invocation.method(#getAvailableCurrencies, [], + {#fixedRate: fixedRate, #active: active}), + returnValue: Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); + @override + _i7.Future<_i2.ChangeNowResponse>> getPairedCurrencies( + {String? ticker, bool? fixedRate}) => + (super.noSuchMethod( + Invocation.method(#getPairedCurrencies, [], + {#ticker: ticker, #fixedRate: fixedRate}), + returnValue: Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i15.Decimal>> getMinimalExchangeAmount( + {String? fromTicker, String? toTicker, String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getMinimalExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #apiKey: apiKey + }), + returnValue: Future<_i2.ChangeNowResponse<_i15.Decimal>>.value( + _FakeChangeNowResponse_0<_i15.Decimal>())) + as _i7.Future<_i2.ChangeNowResponse<_i15.Decimal>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>> + getEstimatedExchangeAmount( + {String? fromTicker, + String? toTicker, + _i15.Decimal? fromAmount, + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getEstimatedExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #fromAmount: fromAmount, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse< + _i16.EstimatedExchangeAmount>>.value( + _FakeChangeNowResponse_0<_i16.EstimatedExchangeAmount>())) + as _i7 + .Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>> + getEstimatedFixedRateExchangeAmount( + {String? fromTicker, + String? toTicker, + _i15.Decimal? fromAmount, + bool? useRateId = true, + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#getEstimatedFixedRateExchangeAmount, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #fromAmount: fromAmount, + #useRateId: useRateId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse< + _i16.EstimatedExchangeAmount>>.value( + _FakeChangeNowResponse_0<_i16.EstimatedExchangeAmount>())) + as _i7 + .Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>>); + @override + _i7.Future<_i2.ChangeNowResponse>> + getAvailableFixedRateMarkets({String? apiKey}) => (super.noSuchMethod( + Invocation.method( + #getAvailableFixedRateMarkets, [], {#apiKey: apiKey}), + returnValue: + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + createStandardExchangeTransaction( + {String? fromTicker, + String? toTicker, + String? receivingAddress, + _i15.Decimal? amount, + String? extraId = r'', + String? userId = r'', + String? contactEmail = r'', + String? refundAddress = r'', + String? refundExtraId = r'', + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#createStandardExchangeTransaction, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #receivingAddress: receivingAddress, + #amount: amount, + #extraId: extraId, + #userId: userId, + #contactEmail: contactEmail, + #refundAddress: refundAddress, + #refundExtraId: refundExtraId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i7 + .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + createFixedRateExchangeTransaction( + {String? fromTicker, + String? toTicker, + String? receivingAddress, + _i15.Decimal? amount, + String? rateId, + String? extraId = r'', + String? userId = r'', + String? contactEmail = r'', + String? refundAddress = r'', + String? refundExtraId = r'', + String? apiKey}) => + (super.noSuchMethod( + Invocation.method(#createFixedRateExchangeTransaction, [], { + #fromTicker: fromTicker, + #toTicker: toTicker, + #receivingAddress: receivingAddress, + #amount: amount, + #rateId: rateId, + #extraId: extraId, + #userId: userId, + #contactEmail: contactEmail, + #refundAddress: refundAddress, + #refundExtraId: refundExtraId, + #apiKey: apiKey + }), + returnValue: Future< + _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i7 + .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + @override + _i7.Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>> + getTransactionStatus({String? id, String? apiKey}) => (super.noSuchMethod( + Invocation.method( + #getTransactionStatus, [], {#id: id, #apiKey: apiKey}), + returnValue: + Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>>.value( + _FakeChangeNowResponse_0<_i18.ExchangeTransactionStatus>())) as _i7 + .Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>>); + @override + _i7.Future<_i2.ChangeNowResponse>> + getAvailableFloatingRatePairs({bool? includePartners = false}) => (super + .noSuchMethod( + Invocation.method(#getAvailableFloatingRatePairs, [], + {#includePartners: includePartners}), + returnValue: + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); }