|
|
@ -3,8 +3,11 @@ package de.tims.tictactoe; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
@ -63,6 +66,21 @@ class GameLogicTest { |
|
|
|
assertEquals(expectedResult.getClass(), realResult.getClass()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void numberOfGUIFieldsTest() { |
|
|
|
int realResult = 0; |
|
|
|
int expectedResult = (int) Math.pow(SIZE, 2); |
|
|
|
|
|
|
|
JPanel gui = game.generateGUI(); |
|
|
|
Component[] components = gui.getComponents(); |
|
|
|
|
|
|
|
for (Component component : components) { |
|
|
|
if (component instanceof JButton) realResult++; |
|
|
|
} |
|
|
|
|
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest(name = "[{index}] {0} -> {2} fields") |
|
|
|
@MethodSource("testCasesForCountPlayfields") |
|
|
|
void fieldCountTest(String testName, int size, int expectedResult) { |
|
|
|