Dao:
@Query("room db query")
fun getSomeItemsDataSource(): DataSource.Factory<Int, SomeEntity>
i have this query for pagination from my room db table. when i want to mock this or use double test class for DataSource.Factory i can't give any list to return or create an instance from it? I cant write unit tests for my viewmodel neither for my resository. It throws NullPointerException as it should be when i use mock. see the usage below:
Repository:
override fun getSomeItemsDataSource(): DataSource.Factory<Int, SomeEntity> =
someDao.getSomeItemsDataSource()
ViewModel:
val someItems: Flow<PagingData<SomeEntity>> =
Pager(
config = PagingConfig(pageSize = 1),
pagingSourceFactory = someRepository
.getSomeItemsDataSource()
.asPagingSourceFactory()
)
.flow
.cachedIn(scope = viewModelScope)