From: David ‘Bombe’ Roden Date: Sun, 20 Nov 2016 12:13:17 +0000 (+0100) Subject: Add unit test for trust accessor X-Git-Tag: 0.9.7^2~410 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c92b45bd8468d06220c58a49b3e0258e72d5756e;p=Sone.git Add unit test for trust accessor --- diff --git a/src/test/kotlin/net/pterodactylus/sone/template/TrustAccessorTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/TrustAccessorTest.kt new file mode 100644 index 0000000..9f2213a --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/template/TrustAccessorTest.kt @@ -0,0 +1,30 @@ +package net.pterodactylus.sone.template + +import net.pterodactylus.sone.freenet.wot.Trust +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test + +/** + * Unit test for [TrustAccessor]. + */ +class TrustAccessorTest { + + private val accessor = TrustAccessor() + + @Test + fun `accessor returns false if there is no explicit trust assigned`() { + assertThat(accessor.get(null, Trust(null, null, null), "assigned"), equalTo(false)) + } + + @Test + fun `accessor returns true if there is explicit trust assigned`() { + assertThat(accessor.get(null, Trust(0, null, null), "assigned"), equalTo(true)) + } + + @Test + fun `reflection accessor is used for other members`() { + assertThat(accessor.get(null, Trust(0, 0, 0), "hashCode"), equalTo(Trust(0, 0, 0).hashCode())) + } + +}