Skip to content

Instantly share code, notes, and snippets.

@lisamariewatkins
Created March 27, 2019 00:15
Show Gist options
  • Save lisamariewatkins/869d617fdf78bfb240d35b00cf11d999 to your computer and use it in GitHub Desktop.
Save lisamariewatkins/869d617fdf78bfb240d35b00cf11d999 to your computer and use it in GitHub Desktop.
@Test
@ExperimentalCoroutinesApi
fun `verify method returns result, caches images, and updates offset`() = runBlocking {
// Arrange
val deferred = CompletableDeferred(MockJsonResponse().with(1))
every {
mockPetManager.getPetListAsync("78701", null)
} returns deferred
// Exercise
val result = petRepository.getNextPet()
// Assert
result.observeForever {
Assert.assertNotNull(it)
}
coVerify {
mockImageCache.cacheImages(any())
}
Assert.assertEquals(deferred.getCompleted().petFinder.lastOffset.value, petRepository.offset)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment