BiometricShieldMock class
A mock implementation of BiometricShieldInterface for testing.
Create an instance with predefined results and pass it to your code under test (dependency injection pattern).
final mockShield = BiometricShieldMock(
authenticateResult: BiometricResult.success(
session: FakeBiometricSession.active(),
token: 'fake-token',
),
);
// Pass mockShield to code under test instead of real BiometricShield
- Implemented types
Constructors
- BiometricShieldMock({BiometricConfig? config, BiometricResult authenticateResult = const BiometricResult.cancelled(), bool hasValidSessionResult = false, BiometricCapability? capabilityResult, String? tokenResult, LockoutState? lockoutStateResult, BiometricSession? sessionStreamResult, bool isEnrolledResult = true, bool enrollResult = true})
Properties
-
authenticateCalls
→ List<
AuthenticateCall> -
Tracks calls to authenticate.
final
- authenticateResult → BiometricResult
-
Result returned by authenticate and validateOrAuthenticate.
final
- capabilityResult → BiometricCapability
-
Result returned by getCapability.
final
- config → BiometricConfig
-
The configuration this instance was created with.
final
-
disposedUsers
→ List<
String> -
Tracks calls to disposeUser.
final
- enrollResult → bool
-
Result returned by enroll.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasValidSessionResult → bool
-
Result returned by hasValidSession.
final
- isEnrolledResult → bool
-
Result returned by isEnrolled.
final
- lockoutStateResult → LockoutState
-
Result returned by getLockoutState.
final
-
onActivityCalls
→ List<
String?> -
Tracks calls to onActivity.
final
- preferences → BiometricPreferences
-
User-facing preferences (enable/disable biometric, remember me, etc).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionStreamResult → BiometricSession?
-
Result returned by sessionStream.
final
-
storedTokens
→ List<
String> -
Tracks calls to storeToken.
final
- tokenResult → String?
-
Result returned by getToken.
final
Methods
-
authenticate(
{required String reason, String? userId, bool requireFresh = false}) → Future< BiometricResult> -
Simulate BiometricShield.authenticate.
override
-
clearAll(
{String? userId}) → Future< void> -
Simulate BiometricShield.clearAll.
override
-
clearSession(
{String? userId}) → Future< void> -
Simulate BiometricShield.clearSession.
override
-
dispose(
) → void -
Simulate BiometricShield.dispose.
override
-
disposeUser(
{required String userId}) → Future< void> -
Simulate BiometricShield.disposeUser.
override
-
enroll(
{String? userId}) → Future< bool> -
Simulate BiometricShield.enroll.
override
-
getCapability(
) → Future< BiometricCapability> -
Simulate BiometricShield.getCapability.
override
-
getLockoutState(
{String? userId}) → Future< LockoutState> -
Simulate BiometricShield.getLockoutState.
override
-
getToken(
{String? userId}) → Future< String?> -
Simulate BiometricShield.getToken.
override
-
hasValidSession(
{String? userId}) → Future< bool> -
Simulate BiometricShield.hasValidSession.
override
-
isEnrolled(
) → Future< bool> -
Simulate BiometricShield.isEnrolled.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onActivity(
{String? userId}) → void -
Simulate BiometricShield.onActivity.
override
-
resetCalls(
) → void - Reset all tracked calls.
-
resetLockout(
{String? userId}) → Future< void> -
Simulate BiometricShield.resetLockout.
override
-
sessionStream(
{String? userId}) → Stream< BiometricSession?> -
Simulate BiometricShield.sessionStream.
override
-
storeToken(
String token, {String? userId}) → Future< void> -
Simulate BiometricShield.storeToken.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
validateOrAuthenticate(
{required String reason, String? userId}) → Future< BiometricResult> -
Simulate BiometricShield.validateOrAuthenticate.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited