Skip to content
Snippets Groups Projects
Commit c3a3ff1b authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

added test

parent 814175a9
No related branches found
No related tags found
No related merge requests found
Pipeline #22062 passed
......@@ -19,6 +19,14 @@ public interface Board<S> {
*/
S getState(Position position);
/**
* Set the state of a specific position on the board to the specified state.
*
* @param state The state to set for the given position.
* @param position The position on the board for which to set the state.
*/
void setState(S state, Position position);
/**
* Get the number of rows in the board.
*
......
......@@ -140,4 +140,14 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
return position;
}
@Override
public void setState(List<ModelElement> state, Position position) {
for(ModelElement element : state){
switch (element){
case FIRE -> firePositions.add(position);
case FIREFIGHTER -> firefighterPositions.add(position);
}
}
}
}
\ No newline at end of file
package firefighter.model;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
public class FirefighterBoardTest {
@Test
void testColumnCount(){
Board<List<ModelElement>> board = new FirefighterBoard(20, 10, 1, 3);
assertThat(board.columnCount()).isEqualTo(20);
}
@Test
void testRowCount(){
Board<List<ModelElement>> board = new FirefighterBoard(20, 10, 1, 3);
assertThat(board.rowCount()).isEqualTo(10);
}
@Test
void testStepNumber(){
Board<List<ModelElement>> board = new FirefighterBoard(20, 10, 1, 3);
for(int index = 0; index < 10; index++){
assertThat(board.stepNumber()).isEqualTo(index);
board.updateToNextGeneration();
}
assertThat(board.stepNumber()).isEqualTo(10);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment