✅ Add test for last-activity comparator
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 16 Feb 2020 20:14:57 +0000 (21:14 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 16 Feb 2020 20:14:57 +0000 (21:14 +0100)
src/test/kotlin/net/pterodactylus/sone/data/SoneTest.kt

index 8866b51..6b7e51d 100644 (file)
@@ -62,6 +62,28 @@ class SoneTest {
        }
 
        @Test
+       fun `last activity comparator correctly compares Sones by last activity`() {
+               val sone1 = object : IdOnlySone("1") {
+                       override fun getTime() = 1000L
+               }
+               val sone2 = object : IdOnlySone("2") {
+                       override fun getTime() = 2000L
+               }
+               assertThat(lastActivityComparator.compare(sone1, sone2), greaterThan(0))
+       }
+
+       @Test
+       fun `last activity comparator treats Sones as equal if last activity is the same`() {
+               val sone1 = object : IdOnlySone("1") {
+                       override fun getTime() = 1000L
+               }
+               val sone2 = object : IdOnlySone("2") {
+                       override fun getTime() = 1000L
+               }
+               assertThat(lastActivityComparator.compare(sone1, sone2), equalTo(0))
+       }
+
+       @Test
        fun `post count comparator sorts sones with different number of posts correctly`() {
                val sone1 = object : IdOnlySone("1") {
                        override fun getPosts() = listOf(createPost(), createPost())