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