package com.github.nullptroma.wallenc.usecases.fakes

import com.github.nullptroma.wallenc.domain.datatypes.EncryptKey
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
import com.github.nullptroma.wallenc.domain.interfaces.IUnlockManager
import com.github.nullptroma.wallenc.domain.interfaces.IVault
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID

class FakeVaultsManager(
    storages: List<IStorage>,
) : IVaultsManager {
    override val vaults: StateFlow<List<IVault>> = MutableStateFlow(emptyList())
    override val allStorages: StateFlow<List<IStorage>> = MutableStateFlow(storages)
    override val unlockManager: IUnlockManager = FakeUnlockManager()
}

class FakeUnlockManager : IUnlockManager {
    override val openedStorages: StateFlow<Map<UUID, IStorage>> = MutableStateFlow(emptyMap())

    override fun getOpenedStorageKey(uuid: UUID): EncryptKey? = null

    override suspend fun open(storage: IStorage, key: EncryptKey, rememberPassword: Boolean): IStorage = storage

    override suspend fun rememberKey(storage: IStorage, key: EncryptKey) = Unit

    override suspend fun close(storage: IStorage) = Unit

    override suspend fun close(uuid: UUID) = Unit
}
