forked from aws-samples/eb-java-scorekeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicTacToeTest.java
More file actions
32 lines (27 loc) · 937 Bytes
/
TicTacToeTest.java
File metadata and controls
32 lines (27 loc) · 937 Bytes
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
package scorekeep;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.junit.jupiter.api.Test;
class TicTacToeTest {
private static final Logger logger = LoggerFactory.getLogger(TicTacToe.class);
@Test
void gameplayTest() {
Rules rules = TicTacToe.getRules();
String state = rules.getInitialState();
List<String> moves = new ArrayList<String>(Arrays.asList("X1", "O3", "X4", "O6", "X7"));
for (String move : moves) {
state = TicTacToe.move(state, move);
}
assertTrue(TicTacToe.checkWin(TicTacToe.toInt(state.toCharArray(), 'X')));
}
@Test
void checkWinTest() {
String state = "OX O XO X";
assertTrue(TicTacToe.checkWin(TicTacToe.toInt(state.toCharArray(), 'X')));
}
}