Issue#13 Finish Robolectric SharedPreferences test description

This commit is contained in:
Gergely Hegedus 2022-01-28 21:42:31 +02:00
parent d29207be12
commit c38e608c8c
6 changed files with 281 additions and 52 deletions

View file

@ -1,30 +0,0 @@
package org.fnives.test.showcase.core.integration.fake
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import org.fnives.test.showcase.core.storage.content.FavouriteContentLocalStorage
import org.fnives.test.showcase.model.content.ContentId
class FakeFavouriteContentLocalStorage : FavouriteContentLocalStorage {
private val dataFlow = MutableSharedFlow<List<ContentId>>(
replay = 1,
onBufferOverflow = BufferOverflow.DROP_OLDEST,
)
init {
dataFlow.tryEmit(emptyList())
}
override fun observeFavourites(): Flow<List<ContentId>> = dataFlow.asSharedFlow()
override suspend fun markAsFavourite(contentId: ContentId) {
dataFlow.emit(dataFlow.replayCache.first().plus(contentId))
}
override suspend fun deleteAsFavourite(contentId: ContentId) {
dataFlow.emit(dataFlow.replayCache.first().minus(contentId))
}
}

View file

@ -1,6 +0,0 @@
package org.fnives.test.showcase.core.integration.fake
import org.fnives.test.showcase.core.storage.UserDataLocalStorage
import org.fnives.test.showcase.model.session.Session
class FakeUserDataLocalStorage(override var session: Session? = null) : UserDataLocalStorage