Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/src/test/kotlin/test/ArgumentCaptorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.nhaarman.expect.expect
import com.nhaarman.expect.expectErrorWithMessage
import java.util.*
import kotlinx.coroutines.runBlocking
import org.junit.Ignore
import org.junit.Test
import org.mockito.kotlin.KArgumentCaptor
import org.mockito.kotlin.any
Expand Down Expand Up @@ -458,4 +459,19 @@ class ArgumentCaptorTest : TestBase() {
runBlocking { captor.firstValue.invoke() }
expect(counter).toBe(1)
}

@Test
@Ignore("Expected: Success(kotlin.Unit) but was: kotlin.Unit")
fun argumentCaptor_Result() {
/* Given */
val m: SynchronousFunctions = mock()

/* When */
m.resultArgument(Result.success(Unit))

/* Then */
val captor = argumentCaptor<Result<Unit>>()
verify(m).resultArgument(captor.capture())
expect(captor.firstValue).toBe(Result.success(Unit))
}
}
2 changes: 2 additions & 0 deletions tests/src/test/kotlin/test/Classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ interface SynchronousFunctions {

fun <T> resultResult(): Result<T>

fun <T> resultArgument(r: Result<T>)

fun functionArgument(function: () -> Unit)

fun suspendFunctionArgument(function: suspend () -> Unit)
Expand Down
20 changes: 20 additions & 0 deletions tests/src/test/kotlin/test/VerificationTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test

import com.nhaarman.expect.expect
import org.junit.Ignore
import org.junit.Test
import org.mockito.exceptions.base.MockitoAssertionError
import org.mockito.kotlin.*
Expand Down Expand Up @@ -108,4 +109,23 @@ class VerificationTest : TestBase() {
verify(this, after(10)).int(3)
}
}

@Test
fun testResultArgument() {
mock<SynchronousFunctions>().apply {
resultArgument(Result.success(Unit))

verify(this).resultArgument(Result.success(Unit))
}
}

@Test
@Ignore("class kotlin.Unit cannot be cast to class kotlin.Result")
fun testResultArgumentWithEq() {
mock<SynchronousFunctions>().apply {
resultArgument(Result.success(Unit))

verify(this).resultArgument(eq(Result.success(Unit)))
}
}
}