1- /*
2- * Copyright (c) 2024 David Allison <davidallisongithub@gmail.com>
3- *
4- * This program is free software; you can redistribute it and/or modify it under
5- * the terms of the GNU General Public License as published by the Free Software
6- * Foundation; either version 3 of the License, or (at your option) any later
7- * version.
8- *
9- * This program is distributed in the hope that it will be useful, but WITHOUT ANY
10- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11- * PARTICULAR PURPOSE. See the GNU General Public License for more details.
12- *
13- * You should have received a copy of the GNU General Public License along with
14- * this program. If not, see <http://www.gnu.org/licenses/>.
15- */
1+ // SPDX-License-Identifier: GPL-3.0-or-later
162
173package com.ichi2.testutils
184
@@ -22,7 +8,7 @@ import timber.log.Timber
228import kotlin.test.fail
239
2410/* *
25- * Ensures no calls to [ChangeManager.notifySubscribers] via [ undoableOp]
11+ * Asserts no calls to [ChangeManager.notifySubscribers] are made (typically via ` undoableOp`)
2612 */
2713suspend fun ensureNoOpsExecuted (block : suspend () -> Unit ) {
2814 val subscription = ChangeCounter ()
@@ -37,7 +23,7 @@ suspend fun ensureNoOpsExecuted(block: suspend () -> Unit) {
3723}
3824
3925/* *
40- * Ensures no calls to [ChangeManager.notifySubscribers] via [undoableOp ]
26+ * Asserts [count] calls are made to [ChangeManager.notifySubscribers]
4127 */
4228suspend fun ensureOpsExecuted (
4329 count : Int ,
@@ -53,11 +39,11 @@ suspend fun ensureOpsExecuted(
5339 return
5440 }
5541
56- fail(" ChangeManager: expected $count calls; ${ChangeManager .subscriberCount} subscribers" )
42+ fail(" ChangeManager: expected $count calls, got ${subscription.changeCount} ; ${ChangeManager .subscriberCount} subscribers" )
5743}
5844
5945/* *
60- * Ensures that [ChangeManager.notifySubscribers] is called with [handler] as the handler
46+ * Asserts that [ChangeManager.notifySubscribers] is called with [handler] as the handler
6147 */
6248suspend fun ensureOpWithHandler (
6349 handler : Any ,
0 commit comments