Last active
February 10, 2020 21:23
-
-
Save lukaszkalnik/341b724eb92196135a1b23da82054b6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class GetLightsUseCaseTest { | |
private val testEntity = TestClassesProvider.entity() | |
private val mockApi = mockk<GatewayApi>() | |
private val lights = listOf(Light(id = "1234")) | |
private val mockConverter = mockk<EntityConverter<List<Light>>> converter@{ | |
every { [email protected](testEntity) } returns lights | |
} | |
private val useCase = getLightsUseCaseFactory(mockApi, mockConverter) | |
@Test | |
fun `calling use case with response success should return list of lights`() { | |
val roomId = "room 1" | |
coEvery { mockApi.getLights(roomId) } returns Response.success(testEntity) | |
val result = runBlocking { useCase(roomId) } | |
coVerifyAll { mockApi.getLights(roomId) } | |
verifyAll { mockConverter(testEntity) } | |
assertThat(result).isInstanceOf(Success::class.java) | |
result as Success | |
assertThat(result.success).isEqualTo(lights) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment