Add test for SonePart
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Oct 2016 19:18:00 +0000 (21:18 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Oct 2016 19:18:00 +0000 (21:18 +0200)
src/test/java/net/pterodactylus/sone/text/SonePartTest.java [new file with mode: 0644]

diff --git a/src/test/java/net/pterodactylus/sone/text/SonePartTest.java b/src/test/java/net/pterodactylus/sone/text/SonePartTest.java
new file mode 100644 (file)
index 0000000..6ca2858
--- /dev/null
@@ -0,0 +1,37 @@
+package net.pterodactylus.sone.text;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import net.pterodactylus.sone.data.Profile;
+import net.pterodactylus.sone.data.Sone;
+
+import org.hamcrest.MatcherAssert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Unit test for {@link SonePart}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SonePartTest {
+
+       private final Sone sone = mock(Sone.class);
+       private final SonePart part = new SonePart(sone);
+
+       @Test
+       public void soneIsRetainedCorrectly() {
+           assertThat(part.getSone(), is(sone));
+       }
+
+       @Test
+       public void textIsConstructedFromSonesNiceName() {
+           when(sone.getProfile()).thenReturn(mock(Profile.class));
+               when(sone.getName()).thenReturn("sone");
+               assertThat(part.getText(), is("sone"));
+       }
+
+}