forked from github/wulkanowy-mirror
Add lucky numbers (#216)
This commit is contained in:

committed by
Rafał Borcz

parent
d3c13b8fc3
commit
4da812af39
@ -0,0 +1,44 @@
|
||||
package io.github.wulkanowy.data.repositories.remote
|
||||
|
||||
import io.github.wulkanowy.api.Api
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.impl.annotations.SpyK
|
||||
import io.reactivex.Maybe
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.threeten.bp.LocalDate
|
||||
|
||||
class LuckyNumberRemoteTest {
|
||||
|
||||
@SpyK
|
||||
private var mockApi = Api()
|
||||
|
||||
@MockK
|
||||
private lateinit var semesterMock: Semester
|
||||
|
||||
@Before
|
||||
fun initApi() {
|
||||
MockKAnnotations.init(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getLuckyNumberTest() {
|
||||
every { mockApi.getLuckyNumber() } returns Maybe.just(14)
|
||||
|
||||
every { mockApi.diaryId } returns 1
|
||||
every { semesterMock.studentId } returns 1
|
||||
every { semesterMock.diaryId } returns 1
|
||||
|
||||
val luckyNumber = LuckyNumberRemote(mockApi)
|
||||
.getLuckyNumber(semesterMock)
|
||||
.blockingGet()
|
||||
|
||||
assertEquals(14, luckyNumber.luckyNumber)
|
||||
assertEquals(LocalDate.now(), luckyNumber.date)
|
||||
assertEquals(semesterMock.studentId, luckyNumber.studentId)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user