File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2
tests/src/test/kotlin/test Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,23 @@ fun inOrder(
199
199
Mockito .inOrder(* mocks).evaluation()
200
200
}
201
201
202
+ /* *
203
+ * Allows [InOrder] verification for a single mocked instance:
204
+ *
205
+ * mock.inOrder {
206
+ * verify().foo()
207
+ * }
208
+ *
209
+ */
210
+ inline fun <T > T.inOrder (block : InOrderOnType <T >.() -> Any ) {
211
+ block.invoke(InOrderOnType (this ))
212
+ }
213
+
214
+ class InOrderOnType <T >(private val t : T ) : InOrder by inOrder(t as Any ) {
215
+
216
+ fun verify (): T = verify(t)
217
+ }
218
+
202
219
/* *
203
220
* Allows checking if given method was the only one invoked.
204
221
*/
Original file line number Diff line number Diff line change @@ -64,6 +64,23 @@ class VerificationTest : TestBase() {
64
64
}
65
65
}
66
66
67
+ @Test
68
+ fun testInOrderWithReceiver () {
69
+ /* Given */
70
+ val mock = mock<Methods >()
71
+
72
+ /* When */
73
+ mock.string(" " )
74
+ mock.int(0 )
75
+
76
+ /* Then */
77
+ mock.inOrder {
78
+ verify().string(any())
79
+ verify().int(any())
80
+ verifyNoMoreInteractions()
81
+ }
82
+ }
83
+
67
84
@Test
68
85
fun testClearInvocations () {
69
86
val mock = mock<Methods >().apply {
You can’t perform that action at this time.
0 commit comments