FakeDeviceHardwareRepository

A test double for DeviceHardwareRepository backed by an in-memory map keyed by (hwModel, target).

Call setHardware (or setHardwareForModel) to seed results, or setResult to control the exact Result returned for a given lookup. By default, lookups return Result.success(null).

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Records every getDeviceHardwareByModel invocation for assertion.

Functions

Link copied to clipboard
open suspend override fun getDeviceHardwareByModel(hwModel: Int, target: String?, forceRefresh: Boolean): Result<DeviceHardware?>
Link copied to clipboard
open fun reset()

Resets all registered state flows and custom actions to their initial state.

Link copied to clipboard
fun setHardware(hwModel: Int, target: String? = null, device: DeviceHardware?)

Seeds a successful lookup for the given model/target pair.

Link copied to clipboard
fun setHardwareForModel(hwModel: Int, device: DeviceHardware?)

Seeds a successful lookup for any target of the given model.

Link copied to clipboard
fun setResult(hwModel: Int, target: String? = null, result: Result<DeviceHardware?>)

Seeds an arbitrary Result for the given lookup (use to test failure paths).