-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathTicTacToeTests.java
More file actions
78 lines (57 loc) · 1.59 KB
/
Copy pathTicTacToeTests.java
File metadata and controls
78 lines (57 loc) · 1.59 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.acme.tictactoe.model;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
/**
* There are a lot more tests we can and should write but for now, just a few smoke tests.
*/
public class TicTacToeTests {
private Board board;
@Before
public void setup() {
board = new Board();
}
/**
* This test will simulate and verify x is the winner.
*
* X | X | X
* O | |
* | O |
*/
@Test
public void test3inRowAcrossTopForX() {
board.mark(0,0); // x
assertNull(board.getWinner());
board.mark(1,0); // o
assertNull(board.getWinner());
board.mark(0,1); // x
assertNull(board.getWinner());
board.mark(2,1); // o
assertNull(board.getWinner());
board.mark(0,2); // x
assertEquals(Player.X, board.getWinner());
}
/**
* This test will simulate and verify o is the winner.
*
* O | X | X
* | O |
* | X | O
*/
@Test
public void test3inRowDiagonalFromTopLeftToBottomForO() {
board.mark(0,1); // x
assertNull(board.getWinner());
board.mark(0,0); // o
assertNull(board.getWinner());
board.mark(2,1); // x
assertNull(board.getWinner());
board.mark(1,1); // o
assertNull(board.getWinner());
board.mark(0,2); // x
assertNull(board.getWinner());
board.mark(2,2); // o
assertEquals(Player.O, board.getWinner());
}
}