Skip to content

Commit

Permalink
Test: Fix ConnectFourTest cases and add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Jan 22, 2024
1 parent 30d7c95 commit 39887fb
Showing 1 changed file with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;

Expand All @@ -22,7 +23,26 @@ class TestGetActions {

@Test
void testGetAllActionsAtStart() {
int expected = 7;
int expected = 6;
int actual = connectFour.getActions().size();
assertEquals(expected, actual);
}

@Test
void testGetAllActionsAfterOneMove() {
int expected = 6;
connectFour.result(connectFour.getActions().get(0));
int actual = connectFour.getActions().size();
assertEquals(expected, actual);
}

@Test
void testGetAllActionsAfterColumnIsFull() {
int expected = 6;
int coloumnHeight = 7;
for (int i = 0; i < coloumnHeight; i++) {
connectFour = (ConnectFour) connectFour.result(connectFour.getActions().get(0));
}
int actual = connectFour.getActions().size();
assertEquals(expected, actual);
}
Expand All @@ -49,13 +69,20 @@ void testIsTerminalAfterLessThenPossibleWinningCombination() {
boolean expected = false;
int numberOfMoves = 3;
for (int i = 0; i < numberOfMoves; i++) {
connectFour.result(connectFour.getActions().get(0));
connectFour.result(connectFour.getActions().get(1));
connectFour = (ConnectFour) connectFour.result(connectFour.getActions().get(0));
connectFour = (ConnectFour) connectFour.result(connectFour.getActions().get(1));
}
boolean actual = connectFour.isTerminal();
assertEquals(expected, actual);
}

@Test
void testIsTerminalAfterGameIsWon() {
boolean expected = true;
connectFour = (ConnectFour) connectFour.result(connectFour.getActions().get(0));

}

}

@Test
Expand Down

0 comments on commit 39887fb

Please sign in to comment.