import 'package:cake_wallet/core/auth_service.dart'; import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/authentication_store.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/wallet_list_store.dart'; import 'package:cake_wallet/view_model/link_view_model.dart'; import 'package:hive/hive.dart'; import 'package:mocktail/mocktail.dart'; import 'mocks.dart'; class TestHelpers { static void setup() { // Fallback values can also be declared here registerDependencies(); } static void registerDependencies() { getAndRegisterAppStore(); getAndRegisterAuthService(); getAndRegisterSettingsStore(); getAndRegisterAuthenticationStore(); getAndRegisterWalletListStore(); getAndRegisterLinkViewModel(); getAndRegisterSecureStorage(); getAndRegisterHiveInterface(); } static MockSettingsStore getAndRegisterSettingsStore() { _removeRegistrationIfExists(); final service = MockSettingsStore(); getIt.registerSingleton(service); return service; } static MockAppStore getAndRegisterAppStore() { _removeRegistrationIfExists(); final service = MockAppStore(); final settingsStore = getAndRegisterSettingsStore(); when(() => service.settingsStore).thenAnswer((invocation) => settingsStore); getIt.registerSingleton(service); return service; } static MockAuthService getAndRegisterAuthService() { _removeRegistrationIfExists(); final service = MockAuthService(); getIt.registerSingleton(service); return service; } static MockAuthenticationStore getAndRegisterAuthenticationStore() { _removeRegistrationIfExists(); final service = MockAuthenticationStore(); when(() => service.state).thenReturn(AuthenticationState.uninitialized); getIt.registerSingleton(service); return service; } static MockWalletListStore getAndRegisterWalletListStore() { _removeRegistrationIfExists(); final service = MockWalletListStore(); getIt.registerSingleton(service); return service; } static MockLinkViewModel getAndRegisterLinkViewModel() { _removeRegistrationIfExists(); final service = MockLinkViewModel(); getIt.registerSingleton(service); return service; } static MockHiveInterface getAndRegisterHiveInterface() { _removeRegistrationIfExists(); final service = MockHiveInterface(); final box = MockHiveBox(); getIt.registerSingleton(service); return service; } static MockSecureStorage getAndRegisterSecureStorage() { _removeRegistrationIfExists(); final service = MockSecureStorage(); getIt.registerSingleton(service); return service; } static void _removeRegistrationIfExists() { if (getIt.isRegistered()) { getIt.unregister(); } } static void tearDown() => getIt.reset(); }