Add run method to EnsureCalledOnce and EnsureCalledOnceWithParam to ensure that assertSuccess is always called.
This commit is contained in:
parent
dee8008917
commit
2c667a0dc0
2 changed files with 47 additions and 37 deletions
|
|
@ -27,6 +27,11 @@ class EnsureCalledOnce : () -> Unit {
|
|||
throw AssertionError("Expected to be called once, but was called $counter times")
|
||||
}
|
||||
}
|
||||
|
||||
fun run(block: (callback: EnsureCalledOnce) -> Unit) {
|
||||
block(this)
|
||||
assertSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
class EnsureCalledOnceWithParam<T>(
|
||||
|
|
@ -45,4 +50,9 @@ 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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue