|
1 | 1 | import org.junit.Ignore;
|
2 |
| -import org.junit.Before; |
3 | 2 | import org.junit.Test;
|
4 | 3 |
|
5 |
| -import static java.util.Arrays.asList; |
6 |
| -import static java.util.Collections.emptyList; |
7 |
| -import static java.util.Collections.singletonList; |
8 |
| -import static org.junit.Assert.assertEquals; |
| 4 | +import static org.assertj.core.api.Assertions.assertThat; |
9 | 5 |
|
10 | 6 | public class HandshakeCalculatorTest {
|
11 | 7 |
|
12 |
| - private HandshakeCalculator handshakeCalculator; |
13 |
| - |
14 |
| - @Before |
15 |
| - public void setUp() { |
16 |
| - handshakeCalculator = new HandshakeCalculator(); |
17 |
| - } |
| 8 | + private final HandshakeCalculator handshakeCalculator = new HandshakeCalculator(); |
18 | 9 |
|
19 | 10 | @Test
|
20 | 11 | public void testThatInput1YieldsAWink() {
|
21 |
| - assertEquals( |
22 |
| - singletonList(Signal.WINK), |
23 |
| - handshakeCalculator.calculateHandshake(1)); |
| 12 | + assertThat(handshakeCalculator.calculateHandshake(1)).containsExactly(Signal.WINK); |
24 | 13 | }
|
25 | 14 |
|
26 | 15 | @Ignore("Remove to run test")
|
27 | 16 | @Test
|
28 | 17 | public void testThatInput2YieldsADoubleBlink() {
|
29 |
| - assertEquals( |
30 |
| - singletonList(Signal.DOUBLE_BLINK), |
31 |
| - handshakeCalculator.calculateHandshake(2)); |
| 18 | + assertThat(handshakeCalculator.calculateHandshake(2)).containsExactly(Signal.DOUBLE_BLINK); |
32 | 19 | }
|
33 | 20 |
|
34 | 21 | @Ignore("Remove to run test")
|
35 | 22 | @Test
|
36 | 23 | public void testThatInput4YieldsACloseYourEyes() {
|
37 |
| - assertEquals( |
38 |
| - singletonList(Signal.CLOSE_YOUR_EYES), |
39 |
| - handshakeCalculator.calculateHandshake(4)); |
| 24 | + assertThat(handshakeCalculator.calculateHandshake(4)).containsExactly(Signal.CLOSE_YOUR_EYES); |
40 | 25 | }
|
41 | 26 |
|
42 | 27 | @Ignore("Remove to run test")
|
43 | 28 | @Test
|
44 | 29 | public void testThatInput8YieldsAJump() {
|
45 |
| - assertEquals( |
46 |
| - singletonList(Signal.JUMP), |
47 |
| - handshakeCalculator.calculateHandshake(8)); |
| 30 | + assertThat(handshakeCalculator.calculateHandshake(8)).containsExactly(Signal.JUMP); |
48 | 31 | }
|
49 | 32 |
|
50 | 33 | @Ignore("Remove to run test")
|
51 | 34 | @Test
|
52 | 35 | public void testAnInputThatYieldsTwoActions() {
|
53 |
| - assertEquals( |
54 |
| - asList(Signal.WINK, Signal.DOUBLE_BLINK), |
55 |
| - handshakeCalculator.calculateHandshake(3)); |
| 36 | + assertThat(handshakeCalculator.calculateHandshake(3)) |
| 37 | + .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK); |
56 | 38 | }
|
57 | 39 |
|
58 | 40 | @Ignore("Remove to run test")
|
59 | 41 | @Test
|
60 | 42 | public void testAnInputThatYieldsTwoReversedActions() {
|
61 |
| - assertEquals( |
62 |
| - asList(Signal.DOUBLE_BLINK, Signal.WINK), |
63 |
| - handshakeCalculator.calculateHandshake(19)); |
| 43 | + assertThat(handshakeCalculator.calculateHandshake(19)) |
| 44 | + .containsExactly(Signal.DOUBLE_BLINK, Signal.WINK); |
64 | 45 | }
|
65 | 46 |
|
66 | 47 | @Ignore("Remove to run test")
|
67 | 48 | @Test
|
68 | 49 | public void testReversingASingleActionYieldsTheSameAction() {
|
69 |
| - assertEquals( |
70 |
| - singletonList(Signal.JUMP), |
71 |
| - handshakeCalculator.calculateHandshake(24)); |
| 50 | + assertThat(handshakeCalculator.calculateHandshake(24)).containsExactly(Signal.JUMP); |
72 | 51 | }
|
73 | 52 |
|
74 | 53 | @Ignore("Remove to run test")
|
75 | 54 | @Test
|
76 | 55 | public void testReversingNoActionsYieldsNoActions() {
|
77 |
| - assertEquals( |
78 |
| - emptyList(), |
79 |
| - handshakeCalculator.calculateHandshake(16)); |
| 56 | + assertThat(handshakeCalculator.calculateHandshake(16)).isEmpty(); |
80 | 57 | }
|
81 | 58 |
|
82 | 59 | @Ignore("Remove to run test")
|
83 | 60 | @Test
|
84 | 61 | public void testInputThatYieldsAllActions() {
|
85 |
| - assertEquals( |
86 |
| - asList(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP), |
87 |
| - handshakeCalculator.calculateHandshake(15)); |
| 62 | + assertThat(handshakeCalculator.calculateHandshake(15)) |
| 63 | + .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP); |
88 | 64 | }
|
89 | 65 |
|
90 | 66 | @Ignore("Remove to run test")
|
91 | 67 | @Test
|
92 | 68 | public void testInputThatYieldsAllActionsReversed() {
|
93 |
| - assertEquals( |
94 |
| - asList(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK), |
95 |
| - handshakeCalculator.calculateHandshake(31)); |
| 69 | + assertThat(handshakeCalculator.calculateHandshake(31)) |
| 70 | + .containsExactly(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK); |
96 | 71 | }
|
97 | 72 |
|
98 | 73 | @Ignore("Remove to run test")
|
99 | 74 | @Test
|
100 | 75 | public void testThatInput0YieldsNoActions() {
|
101 |
| - assertEquals( |
102 |
| - emptyList(), |
103 |
| - handshakeCalculator.calculateHandshake(0)); |
| 76 | + assertThat(handshakeCalculator.calculateHandshake(0)).isEmpty(); |
104 | 77 | }
|
105 | 78 |
|
106 | 79 | @Ignore("Remove to run test")
|
107 | 80 | @Test
|
108 | 81 | public void testThatHandlesMoreThanFiveBinaryPlacesWithReversal() {
|
109 |
| - assertEquals( |
110 |
| - asList(Signal.DOUBLE_BLINK, Signal.WINK), |
111 |
| - handshakeCalculator.calculateHandshake(51)); |
| 82 | + assertThat(handshakeCalculator.calculateHandshake(51)) |
| 83 | + .containsExactly(Signal.DOUBLE_BLINK, Signal.WINK); |
112 | 84 | }
|
113 | 85 |
|
114 | 86 | @Ignore("Remove to run test")
|
115 | 87 | @Test
|
116 | 88 | public void testThatHandlesMoreThanFiveBinaryPlacesWithoutReversal() {
|
117 |
| - assertEquals( |
118 |
| - asList(Signal.WINK, Signal.DOUBLE_BLINK), |
119 |
| - handshakeCalculator.calculateHandshake(35)); |
| 89 | + assertThat(handshakeCalculator.calculateHandshake(35)) |
| 90 | + .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK); |
120 | 91 | }
|
121 | 92 |
|
122 | 93 | @Ignore("Remove to run test")
|
123 | 94 | @Test
|
124 | 95 | public void testInputThatYieldsAllActionsFromMoreThanFiveBinaryPlaces() {
|
125 |
| - assertEquals( |
126 |
| - asList(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP), |
127 |
| - handshakeCalculator.calculateHandshake(111)); |
| 96 | + assertThat(handshakeCalculator.calculateHandshake(111)) |
| 97 | + .containsExactly(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP); |
128 | 98 | }
|
129 | 99 |
|
130 | 100 | }
|
0 commit comments