aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt35
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt (renamed from core/src/test/kotlin/ca/allanwang/kprefs/library/UtilsTest.kt)4
2 files changed, 36 insertions, 3 deletions
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
new file mode 100644
index 0000000..1997bd1
--- /dev/null
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
@@ -0,0 +1,35 @@
+package ca.allanwang.kau.kotlin
+
+import org.junit.Before
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNotEquals
+
+/**
+ * Created by Allan Wang on 2017-07-29.
+ */
+class LazyResettableTest {
+
+ lateinit var registry: LazyResettableRegistry
+
+ @Before
+ fun init() {
+ registry = LazyResettableRegistry()
+ }
+
+ @Test
+ fun basic() {
+ val timeDelegate = lazyResettable { System.currentTimeMillis() }
+ val time: Long by timeDelegate
+ registry.add(timeDelegate)
+ val t1 = time
+ Thread.sleep(5)
+ val t2 = time
+ registry.invalidateAll()
+ Thread.sleep(5)
+ val t3 = time
+ assertEquals(t1, t2, "Lazy resettable not returning same value after second call")
+ assertNotEquals(t1, t3, "Lazy resettable not invalidated by registry")
+ }
+
+} \ No newline at end of file
diff --git a/core/src/test/kotlin/ca/allanwang/kprefs/library/UtilsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
index c2c96e4..071ee9c 100644
--- a/core/src/test/kotlin/ca/allanwang/kprefs/library/UtilsTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
@@ -1,8 +1,6 @@
-package ca.allanwang.kprefs.library
+package ca.allanwang.kau.utils
import android.graphics.Color
-import ca.allanwang.kau.utils.round
-import ca.allanwang.kau.utils.toHexString
import org.junit.Test
import kotlin.test.assertEquals