MockVelo<T> class
A mock implementation of Velo for testing purposes.
This class provides additional testing capabilities such as:
- State history tracking with memory leak prevention
- Emission verification methods
- State disposal detection
- Automatic cleanup and validation
Example:
void main() {
group('CounterVelo', () {
test('should increment counter', () {
final mockVelo = MockVelo<int>(0);
mockVelo.emit(1);
mockVelo.emit(2);
mockVelo.verifyStatesEmittedInOrder([1, 2]);
expect(mockVelo.emittedStates, [1, 2]);
mockVelo.dispose();
});
});
}
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
T> - MockVelo
Properties
-
emittedStates
→ List<
T> -
List of all states that have been emitted (excluding initial state).
Returns a copy to prevent external modification.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- historySize → int
-
Gets the history size for memory monitoring.
no setter
- isHistoryNearLimit → bool
-
Gets whether the history size is approaching the limit.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → T
-
Gets the current state.
no setterinherited
-
stateHistory
→ List<
T> -
List of all states that have been emitted, including the initial state.
Returns a copy to prevent external modification.
no setter
- value ↔ T
-
The current value stored in this notifier.
getter/setter pairinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clearHistory(
) → void - Clears the state history while keeping the current state.
-
dispose(
) → void -
Disposes the mock and clears all state history.
override
-
emit(
T state) → void - Emits a new state and adds it to the history.
-
emitAsync(
Future< T> futureState) → Future<void> -
Emits a state from a Future.
inherited
-
getEmissionCount(
T targetState) → int - Gets the number of times a specific state was emitted.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
verifyNoStatesEmitted(
) → void - Verifies that no states have been emitted (only initial state exists).
-
verifyStateEmitted(
T expectedState) → void - Verifies that the specified state was emitted.
-
verifyStatesEmittedInOrder(
List< T> expectedStates) → void - Verifies that states were emitted in the specified order.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited