File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,14 @@ fun ignoreStubs(vararg mocks: Any): Array<out Any> = Mockito.ignoreStubs(*mocks)
116
116
fun inOrder (vararg mocks : Any ): InOrder = Mockito .inOrder(* mocks)!!
117
117
fun inOrder (vararg mocks : Any , evaluation : InOrder .() -> Unit ) = Mockito .inOrder(* mocks).evaluation()
118
118
119
+ inline fun <T > T.inOrder (block : InOrderOnType <T >.() -> Any ) {
120
+ block.invoke(InOrderOnType (this ))
121
+ }
122
+
123
+ class InOrderOnType <T >(private val t : T ) : InOrder by inOrder(t as Any ) {
124
+ fun verify () : T = verify(t)
125
+ }
126
+
119
127
inline fun <reified T : Any > isA (): T = Mockito .isA(T ::class .java) ? : createInstance<T >()
120
128
fun <T : Any > isNotNull (): T ? = Mockito .isNotNull()
121
129
fun <T : Any > isNull (): T ? = Mockito .isNull()
Original file line number Diff line number Diff line change @@ -225,6 +225,23 @@ class MockitoTest : TestBase() {
225
225
}
226
226
}
227
227
228
+ @Test
229
+ fun testInOrderWithReceiver () {
230
+ /* Given */
231
+ val mock = mock<Methods >()
232
+
233
+ /* When */
234
+ mock.string(" " )
235
+ mock.int(0 )
236
+
237
+ /* Then */
238
+ mock.inOrder {
239
+ verify().string(any())
240
+ verify().int(any())
241
+ verifyNoMoreInteractions()
242
+ }
243
+ }
244
+
228
245
@Test
229
246
fun testClearInvocations () {
230
247
val mock = mock<Methods >().apply {
You can’t perform that action at this time.
0 commit comments