X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneComparisonTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneComparisonTest.kt;h=f79d73650107434415c6ead694420fa8495f7874;hp=0000000000000000000000000000000000000000;hb=03cec6a6772c2d836d94864adddaf544cbe9d72f;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneComparisonTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneComparisonTest.kt new file mode 100644 index 0000000..f79d736 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneComparisonTest.kt @@ -0,0 +1,50 @@ +package net.pterodactylus.sone.core + +import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.test.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* + +class SoneComparsisonTest { + + private val oldSone = mock() + private val newSone = mock() + + private val oldPost = mock() + private val removedPost = mock() + private val newPost = mock() + private val oldPostReply = mock() + private val removedPostReply = mock() + private val newPostReply = mock() + + init { + whenever(oldSone.posts).thenReturn(listOf(oldPost, removedPost)) + whenever(newSone.posts).thenReturn(listOf(oldPost, newPost)) + whenever(oldSone.replies).thenReturn(setOf(oldPostReply, removedPostReply)) + whenever(newSone.replies).thenReturn(setOf(oldPostReply, newPostReply)) + } + + private val soneComparison = SoneComparison(oldSone, newSone) + + @Test + fun `new posts are identified correctly`() { + assertThat(soneComparison.newPosts, contains(newPost)) + } + + @Test + fun `removed posts are identified correctly`() { + assertThat(soneComparison.removedPosts, contains(removedPost)) + } + + @Test + fun `new post replies are identified correctly`() { + assertThat(soneComparison.newPostReplies, contains(newPostReply)) + } + + @Test + fun `removed post replies are identified correctly`() { + assertThat(soneComparison.removedPostReplies, contains(removedPostReply)) + } + +}