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)
116116fun inOrder (vararg mocks : Any ): InOrder = Mockito .inOrder(* mocks)!!
117117fun inOrder (vararg mocks : Any , evaluation : InOrder .() -> Unit ) = Mockito .inOrder(* mocks).evaluation()
118118
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+
119127inline fun <reified T : Any > isA (): T = Mockito .isA(T ::class .java) ? : createInstance<T >()
120128fun <T : Any > isNotNull (): T ? = Mockito .isNotNull()
121129fun <T : Any > isNull (): T ? = Mockito .isNull()
Original file line number Diff line number Diff line change @@ -225,6 +225,23 @@ class MockitoTest : TestBase() {
225225 }
226226 }
227227
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+
228245 @Test
229246 fun testClearInvocations () {
230247 val mock = mock<Methods >().apply {
You can’t perform that action at this time.
0 commit comments