2025-08-08 08:13:58 +03:00
|
|
|
import 'package:cherrypick/cherrypick.dart';
|
|
|
|
|
|
2025-08-11 18:01:21 +03:00
|
|
|
class MockObserver implements CherryPickObserver {
|
|
|
|
|
final List<String> diagnostics = [];
|
|
|
|
|
final List<String> warnings = [];
|
2025-08-08 08:13:58 +03:00
|
|
|
final List<String> errors = [];
|
2025-08-11 18:01:21 +03:00
|
|
|
final List<List<String>> cycles = [];
|
|
|
|
|
final List<String> bindings = [];
|
2025-08-08 08:13:58 +03:00
|
|
|
|
|
|
|
|
@override
|
2025-08-11 18:01:21 +03:00
|
|
|
void onDiagnostic(String message, {Object? details}) =>
|
|
|
|
|
diagnostics.add(message);
|
|
|
|
|
|
2025-08-08 08:13:58 +03:00
|
|
|
@override
|
2025-08-11 18:01:21 +03:00
|
|
|
void onWarning(String message, {Object? details}) => warnings.add(message);
|
|
|
|
|
|
2025-08-08 08:13:58 +03:00
|
|
|
@override
|
2025-08-13 15:38:44 +03:00
|
|
|
void onError(String message, Object? error, StackTrace? stackTrace) => errors.add(
|
|
|
|
|
'$message${error != null ? ' $error' : ''}${stackTrace != null ? '\n$stackTrace' : ''}');
|
2025-08-11 18:01:21 +03:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onCycleDetected(List<String> chain, {String? scopeName}) =>
|
|
|
|
|
cycles.add(chain);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onBindingRegistered(String name, Type type, {String? scopeName}) =>
|
|
|
|
|
bindings.add('$name $type');
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onInstanceRequested(String name, Type type, {String? scopeName}) {}
|
|
|
|
|
@override
|
2025-08-13 15:38:44 +03:00
|
|
|
void onInstanceCreated(String name, Type type, Object instance,
|
|
|
|
|
{String? scopeName}) {}
|
2025-08-11 18:01:21 +03:00
|
|
|
@override
|
2025-08-13 15:38:44 +03:00
|
|
|
void onInstanceDisposed(String name, Type type, Object instance,
|
|
|
|
|
{String? scopeName}) {}
|
2025-08-11 18:01:21 +03:00
|
|
|
@override
|
|
|
|
|
void onModulesInstalled(List<String> moduleNames, {String? scopeName}) {}
|
|
|
|
|
@override
|
|
|
|
|
void onModulesRemoved(List<String> moduleNames, {String? scopeName}) {}
|
|
|
|
|
@override
|
|
|
|
|
void onScopeOpened(String name) {}
|
|
|
|
|
@override
|
|
|
|
|
void onScopeClosed(String name) {}
|
|
|
|
|
@override
|
|
|
|
|
void onCacheHit(String name, Type type, {String? scopeName}) {}
|
|
|
|
|
@override
|
|
|
|
|
void onCacheMiss(String name, Type type, {String? scopeName}) {}
|
2025-08-08 08:13:58 +03:00
|
|
|
}
|