|
|
@ -81,18 +81,6 @@ class GameLogicTest { |
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void buttonStateTest() { |
|
|
|
boolean expectedResult = true; |
|
|
|
game.generateGUI(); |
|
|
|
|
|
|
|
JButton currentField = game.getGUIField(0); |
|
|
|
((JButton) currentField).doClick(); |
|
|
|
boolean realResult = currentField.isEnabled(); |
|
|
|
|
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest(name = "[{index}] {0} -> {2} fields") |
|
|
|
@MethodSource("testCasesForCountPlayfields") |
|
|
|
void fieldCountTest(String testName, int size, int expectedResult) { |
|
|
@ -136,6 +124,18 @@ class GameLogicTest { |
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest(name = "[{index}] {0}: should be {1}") |
|
|
|
@MethodSource("testCasesForCheckButtonState") |
|
|
|
void buttonStateTest(String testName, boolean expectedResult, boolean doClick, int column, int row) { |
|
|
|
game.generateGUI(); |
|
|
|
JButton currentField = game.getGUIField(column, row); |
|
|
|
|
|
|
|
if (doClick) currentField.doClick(); |
|
|
|
boolean realResult = !currentField.getText().isEmpty(); |
|
|
|
|
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForCountPlayfields() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("1x1 board with too few fields", 1, 9), |
|
|
@ -285,5 +285,12 @@ class GameLogicTest { |
|
|
|
{'x', 'o', 'x'}}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForCheckButtonState() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("trigger gui field [0][0]", true, true, 0, 0), |
|
|
|
Arguments.of("dont't trigger gui field [1][1]", false, false, 1, 1) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |