931646b80b16a549290c13897c75244c128d8300
[Sone.git] / src / test / java / net / pterodactylus / sone / text / SonePartTest.java
1 /*
2  * Sone - SonePartTest.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.text;
19
20 import static net.pterodactylus.sone.template.SoneAccessor.getNiceName;
21 import static org.hamcrest.MatcherAssert.assertThat;
22 import static org.hamcrest.Matchers.is;
23 import static org.hamcrest.Matchers.not;
24
25 import net.pterodactylus.sone.data.Mocks;
26 import net.pterodactylus.sone.data.Sone;
27
28 import org.junit.Test;
29
30 /**
31  * Unit test for {@link SonePart}.
32  *
33  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34  */
35 public class SonePartTest {
36
37         private final Mocks mocks = new Mocks();
38         private final Sone sone = mocks.mockSone("Sone").withName("NiceSone").withProfileName("N.", "Ice", "Name").create();
39         private final SonePart sonePart = new SonePart(sone);
40
41         @Test
42         public void sonePartCanStoreAndReturnSone() {
43                 assertThat(sonePart.getSone(), is(sone));
44         }
45
46         @Test
47         public void sonePartTextIsTheNiceNameOfTheSone() {
48                 assertThat(sonePart.getText(), is(getNiceName(sone)));
49         }
50
51         @Test
52         public void twoSonePartsAreEqualIfTheirSonesAreEqual() {
53                 SonePart secondSonePart = new SonePart(sone);
54                 assertThat(sonePart, is(secondSonePart));
55         }
56
57         @Test
58         public void equalSonePartsHaveEqualHashCodes() {
59                 SonePart secondSonePart = new SonePart(sone);
60                 assertThat(sonePart.hashCode(), is(secondSonePart.hashCode()));
61         }
62
63         @Test
64         public void nullIsNotEqualToASonePart() {
65                 assertThat(sonePart, not(is((Object) null)));
66         }
67
68 }