Iterate on EnsureCalledOnce devX
This commit is contained in:
parent
2c667a0dc0
commit
2a6a3ded5e
2 changed files with 16 additions and 14 deletions
|
|
@ -27,11 +27,12 @@ class EnsureCalledOnce : () -> Unit {
|
|||
throw AssertionError("Expected to be called once, but was called $counter times")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun run(block: (callback: EnsureCalledOnce) -> Unit) {
|
||||
block(this)
|
||||
assertSuccess()
|
||||
}
|
||||
fun ensureCalledOnce(block: (callback: EnsureCalledOnce) -> Unit) {
|
||||
val callback = EnsureCalledOnce()
|
||||
block(callback)
|
||||
callback.assertSuccess()
|
||||
}
|
||||
|
||||
class EnsureCalledOnceWithParam<T>(
|
||||
|
|
@ -50,9 +51,10 @@ class EnsureCalledOnceWithParam<T>(
|
|||
throw AssertionError("Expected to be called once, but was called $counter times")
|
||||
}
|
||||
}
|
||||
|
||||
fun run(block: (callback: EnsureCalledOnceWithParam<T>) -> Unit) {
|
||||
block(this)
|
||||
assertSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> ensureCalledOnceWithParam(param: T, block: (callback: EnsureCalledOnceWithParam<T>) -> Unit) {
|
||||
val callback = EnsureCalledOnceWithParam(param)
|
||||
block(callback)
|
||||
callback.assertSuccess()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue