Timur Atakishiev
12/05/2020, 10:42 AMinterface StorageService {
fun upload(inputStream: InputStream): String
}
class LocalStorageService: StorageService {
override upload(inputStream: InputStream): String {
//Some uploading logic
}
}
I want to verify that the function was called with the following code
verify {
storageService.putFile(
inputStream = withArg { assertEquals("Hello, World!".toByteArray(),it.readBytes())}
)
}
and I got an error, that my inputStreams byteArray is empty, can anyone help me pleaseMattia Tommasone
12/06/2020, 9:58 PMverify {
storageService.putFile(match {
it.readBytes() == "Hello, World!".toByteArray()
})
}
val inputStreamSlot = slot<InputStream>()
verify {
storageService.putFile(capture(inputStreamSlot))
}
assertEquals("Hello, World!".toByteArray(), inputStreamSlot.captured.readBytes())
Timur Atakishiev
12/07/2020, 5:37 AMHello, World!
and bytes of an inputStream are not equal. Second one(with the slot
) tells that the inputStreamSlot.captured.readBytes
is emptyevery { storageService.putFile(match{}) }
matcher is working fine, however, in verify section, it is not working. Strangeverify {storageService.upload(inputStream = matcher{it.reset and then it.readBytes() contentEquals "Hello, wordl".toByteArray()}
What do you think is it okay variant?