-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/test/java/com/youtubedl/data/local/ConfigLocalDataSourceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.youtubedl.data.local | ||
|
||
import com.nhaarman.mockito_kotlin.doReturn | ||
import com.nhaarman.mockito_kotlin.mock | ||
import com.nhaarman.mockito_kotlin.verify | ||
import com.youtubedl.data.local.room.dao.ConfigDao | ||
import com.youtubedl.data.local.room.entity.SupportedPage | ||
import io.reactivex.Maybe | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
/** | ||
* Created by cuongpm on 2/17/19. | ||
*/ | ||
class ConfigLocalDataSourceTest { | ||
|
||
private lateinit var configDao: ConfigDao | ||
|
||
private lateinit var configLocalDataSource: ConfigLocalDataSource | ||
|
||
private lateinit var supportedPages: List<SupportedPage> | ||
|
||
@Before | ||
fun setup() { | ||
configDao = mock() | ||
configLocalDataSource = ConfigLocalDataSource(configDao) | ||
supportedPages = listOf(SupportedPage(id = "id1", name = "name1"), SupportedPage(id = "id2", name = "name2")) | ||
} | ||
|
||
@Test | ||
fun `test get supported pages`() { | ||
doReturn(Maybe.just(supportedPages)).`when`(configDao).getSupportedPages() | ||
|
||
configLocalDataSource.getSupportedPages() | ||
.test() | ||
.assertNoErrors() | ||
.assertValue { it == supportedPages } | ||
} | ||
|
||
@Test | ||
fun `test save supported pages`() { | ||
configLocalDataSource.saveSupportedPages(supportedPages) | ||
verify(configDao).insertSupportedPage(supportedPages[0]) | ||
verify(configDao).insertSupportedPage(supportedPages[1]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters