From: David ‘Bombe’ Roden Date: Sun, 16 Feb 2020 20:14:57 +0000 (+0100) Subject: ✅ Add test for last-activity comparator X-Git-Tag: v82^2~62 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=141f56a62e39c13b1eb14fe6e5c3b8b7bc062168 ✅ Add test for last-activity comparator --- diff --git a/src/test/kotlin/net/pterodactylus/sone/data/SoneTest.kt b/src/test/kotlin/net/pterodactylus/sone/data/SoneTest.kt index 8866b51..6b7e51d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/data/SoneTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/data/SoneTest.kt @@ -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())