-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathNextStepLinesTest.java
More file actions
37 lines (29 loc) · 1.28 KB
/
NextStepLinesTest.java
File metadata and controls
37 lines (29 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package nextstep.ladder.domain;
import nextstep.ladder.strategy.LineStrategy;
import nextstep.ladder.strategy.TrueLineStrategy;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class NextStepLinesTest {
public static NextStepLines lines() {
LineStrategy lineStrategy = new TrueLineStrategy();
return new NextStepLines(4, 3, lineStrategy);
}
@Test
void 세명의참가자만큼_네줄로_사다리_생성() {
LineStrategy lineStrategy = new TrueLineStrategy();
NextStepLines nextStepLines = new NextStepLines(3, 4, lineStrategy);
assertThat(nextStepLines.size()).isEqualTo(4);
for (int i = 0; i < nextStepLines.size(); i++) {
assertThatLineSize(nextStepLines, i);
assertThatLinePatternIsCorrect(nextStepLines, i);
}
}
private static void assertThatLinePatternIsCorrect(NextStepLines nextStepLines, int linesIdx) {
for (int j = 0; j < nextStepLines.getLineSize(linesIdx); j++) {
assertThat(nextStepLines.getPoint(linesIdx, j)).isEqualTo(j % 2 == 0);
}
}
private static void assertThatLineSize(NextStepLines nextStepLines, int linesIdx) {
assertThat(nextStepLines.getLineSize(linesIdx)).isEqualTo(2);
}
}