aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin
diff options
context:
space:
mode:
authortherealbush <therealbush@users.noreply.github.com>2022-04-01 19:26:05 -1000
committertherealbush <therealbush@users.noreply.github.com>2022-04-01 19:26:05 -1000
commitf91739108759aea33b0442933ae064c783a1f89d (patch)
treec512908b3a7b7be62708b32c0e4dbd78d655f48d /src/test/kotlin
parent48b57ceb1680af6c426b6f928a403c958b1d3279 (diff)
downloadeventbus-kotlin-f91739108759aea33b0442933ae064c783a1f89d.tar.gz
eventbus-kotlin-f91739108759aea33b0442933ae064c783a1f89d.tar.bz2
eventbus-kotlin-f91739108759aea33b0442933ae064c783a1f89d.zip
almost done, just need to make thread safe, test, and document
Diffstat (limited to 'src/test/kotlin')
-rw-r--r--src/test/kotlin/Test.kt14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/test/kotlin/Test.kt b/src/test/kotlin/Test.kt
index c166cb2..2bdb445 100644
--- a/src/test/kotlin/Test.kt
+++ b/src/test/kotlin/Test.kt
@@ -19,7 +19,7 @@ import kotlin.random.Random
*/
@TestInstance(Lifecycle.PER_CLASS)
class Test {
- lateinit var eventBus: EventBus
+ private lateinit var eventBus: EventBus
private val logger = LogManager.getLogger()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -64,7 +64,7 @@ class Test {
Assertions.assertEquals(random, primitiveTestValue)
}
- var primitiveTestValue = 0
+ private var primitiveTestValue = 0
val primitiveListener = listener<Int> {
primitiveTestValue = it
@@ -73,11 +73,11 @@ class Test {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Tests unsubscribing of "free" listeners which don't belong to a subscriber. todo allow keys to be resubscribed and test top level listeners
+ // Tests unsubscribing of listeners which don't belong to a subscriber.
@Test
fun freeListenerTest() {
- // Register "free" listener, and keep the returned key
- val key = eventBus.register(listener<String> {
+ // Register listener and keep the value
+ val listener = eventBus.register(listener<String> {
freeListenerTestValue = it
})
val valueOne = "i love bush's eventbus <3"
@@ -86,14 +86,14 @@ class Test {
eventBus.post(valueOne)
Assertions.assertEquals(valueOne, freeListenerTestValue)
// Remove the listener
- eventBus.unsubscribe(key)
+ eventBus.unregister(listener)
// No effect
eventBus.post(valueTwo)
// Value will not change
Assertions.assertEquals(valueOne, freeListenerTestValue)
}
- var freeListenerTestValue: String? = null
+ private var freeListenerTestValue: String? = null
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////