Skip to content

Commit 12ae5ce

Browse files
authored
Fix for issue exercism#354: extract common setup
extracted instance construction to setUp() method.
1 parent aa67fef commit 12ae5ce

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.Ignore;
2+
import org.junit.Before;
23
import org.junit.Test;
34

45
import static java.util.Arrays.asList;
@@ -7,100 +8,107 @@
78
import static org.junit.Assert.assertEquals;
89

910
public final class HandshakeCalculatorTest {
10-
11+
private HandshakeCalculator handshakeCalculator;
12+
13+
14+
@Before
15+
public void setUp() {
16+
handshakeCalculator = new HandshakeCalculator();
17+
}
18+
1119
@Test
1220
public void testThatInput1YieldsAWink() {
1321
assertEquals(
1422
singletonList(Signal.WINK),
15-
new HandshakeCalculator().calculateHandshake(1));
23+
handshakeCalculator.calculateHandshake(1));
1624
}
1725

1826
@Ignore
1927
@Test
2028
public void testThatInput2YieldsADoubleBlink() {
2129
assertEquals(
2230
singletonList(Signal.DOUBLE_BLINK),
23-
new HandshakeCalculator().calculateHandshake(2));
31+
handshakeCalculator.calculateHandshake(2));
2432
}
2533

2634
@Ignore
2735
@Test
2836
public void testThatInput4YieldsACloseYourEyes() {
2937
assertEquals(
3038
singletonList(Signal.CLOSE_YOUR_EYES),
31-
new HandshakeCalculator().calculateHandshake(4));
39+
handshakeCalculator.calculateHandshake(4));
3240
}
3341

3442
@Ignore
3543
@Test
3644
public void testThatInput8YieldsAJump() {
3745
assertEquals(
3846
singletonList(Signal.JUMP),
39-
new HandshakeCalculator().calculateHandshake(8));
47+
handshakeCalculator.calculateHandshake(8));
4048
}
4149

4250
@Ignore
4351
@Test
4452
public void testAnInputThatYieldsTwoActions() {
4553
assertEquals(
4654
asList(Signal.WINK, Signal.DOUBLE_BLINK),
47-
new HandshakeCalculator().calculateHandshake(3));
55+
handshakeCalculator.calculateHandshake(3));
4856
}
4957

5058
@Ignore
5159
@Test
5260
public void testAnInputThatYieldsTwoReversedActions() {
5361
assertEquals(
5462
asList(Signal.DOUBLE_BLINK, Signal.WINK),
55-
new HandshakeCalculator().calculateHandshake(19));
63+
handshakeCalculator.calculateHandshake(19));
5664
}
5765

5866
@Ignore
5967
@Test
6068
public void testReversingASingleActionYieldsTheSameAction() {
6169
assertEquals(
6270
singletonList(Signal.JUMP),
63-
new HandshakeCalculator().calculateHandshake(24));
71+
handshakeCalculator.calculateHandshake(24));
6472
}
6573

6674
@Ignore
6775
@Test
6876
public void testReversingNoActionsYieldsNoActions() {
6977
assertEquals(
7078
emptyList(),
71-
new HandshakeCalculator().calculateHandshake(16));
79+
handshakeCalculator.calculateHandshake(16));
7280
}
7381

7482
@Ignore
7583
@Test
7684
public void testInputThatYieldsAllActions() {
7785
assertEquals(
7886
asList(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP),
79-
new HandshakeCalculator().calculateHandshake(15));
87+
handshakeCalculator.calculateHandshake(15));
8088
}
8189

8290
@Ignore
8391
@Test
8492
public void testInputThatYieldsAllActionsReversed() {
8593
assertEquals(
8694
asList(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK),
87-
new HandshakeCalculator().calculateHandshake(31));
95+
handshakeCalculator.calculateHandshake(31));
8896
}
8997

9098
@Ignore
9199
@Test
92100
public void testThatInput0YieldsNoActions() {
93101
assertEquals(
94102
emptyList(),
95-
new HandshakeCalculator().calculateHandshake(0));
103+
handshakeCalculator.calculateHandshake(0));
96104
}
97105

98106
@Ignore
99107
@Test
100108
public void testThatInputWithLower5BitsNotSetYieldsNoActions() {
101109
assertEquals(
102110
emptyList(),
103-
new HandshakeCalculator().calculateHandshake(32));
111+
handshakeCalculator.calculateHandshake(32));
104112
}
105113

106114
}

0 commit comments

Comments
 (0)