Skip to content
Snippets Groups Projects
Select Git revision
  • 45af24776c70dfa6f8cc45dc119c3f681cf50915
  • main default protected
2 results

FloodGameTest.java

Blame
  • Forked from TRAVERS Corentin / flooding-template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    FloodGameTest.java 2.55 KiB
    package model;
    
    import javafx.scene.paint.Color;
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.api.Test;
    
    import static javafx.scene.paint.Color.*;
    import static org.assertj.core.api.Assertions.assertThat;
    
    class FloodGameTest {
    
        // TODO
        //  uncomment
        /*
        private final int totalNumberOfCells = 6;
        private final Grid gridTwoThree = new ArrayGrid(2,3);
        private final Color colorONE = RED;
        private final Color colorTWO = BLUE;
        private FloodGame game;
        private final Player playerONE = new ComputerPlayer("player1", gridTwoThree.getCell(0, 0), startCell -> colorONE);
        private final Player playerTWO = new ComputerPlayer("player2", gridTwoThree.getCell(1, 2), startCell -> colorTWO);
    
        @BeforeEach
        private void initGame(){
            game = new FloodGame(totalNumberOfCells);
        }
    
    
        @Test
        void testSetTurnAndGetTurn() {
            assertThat(game.getTurn()).isEqualTo(0);
            game.setTurn(100);
            assertThat(game.getTurn()).isEqualTo(100);
        }
    
    
    
    
        @Test
        void testResetTurn() {
            game.setTurn(100);
            game.resetTurn();
            assertThat(game.getTurn()).isEqualTo(0);
        }
    
    
        @Test
        void testIncrementTurn() {
            game.incrementTurn();
            game.incrementTurn();
            assertThat(game.getTurn()).isEqualTo(2);
        }
    
        @Test
        void testGetPlayer() {
            game.setPlayer(playerONE);
            game.setPlayer(playerTWO);
            assertThat(game.getPlayer()).isEqualTo(playerTWO);
            game.incrementTurn();
            assertThat(game.getPlayer()).isEqualTo(playerTWO);
        }
    
        @Test
        void testIsHumanTurn() {
            game.setPlayer(new HumanPlayer("human",gridTwoThree.getCell(1,2)));
            assertThat(game.isHumanTurn()).isTrue();
            game.setPlayer(playerONE);
            assertThat(game.isHumanTurn()).isFalse();
        }