mardi 2 mai 2017

JUnit Testing assistance re logic needed

I am trying to formulate a JUnit test for the below code and I am hoping someone might be able to point me in the right direction as I am completely stumped!

public ArrayList<PathData> tileClicked(Coordinate tile){
    ArrayList<PathData> pathData = new ArrayList<>();
    Tile clickedTile = gameBoard.getTile(tile);
    int totalNumPlayers = clickedTile.getNumberOfPlayers();
    Player cur;
    //GuiInstruction guiInstruction = new GuiInstruction();
    //guiInstruction
    if (clickedTile.hasPort()){
        //deal with ports
        for(int j = 0; j < totalNumPlayers; j++){
            cur = clickedTile.getPlayerIndex(j);
            if(cur.equals(currentPlayer)){
                pathData = specialCalculateMove(currentPlayer, true);
            }
        }
    } else if (clickedTile.hasPlayer()){
        for(int i = 0; i < totalNumPlayers; i++){
            cur = clickedTile.getPlayerIndex(i);
            if(cur.equals(currentPlayer)){ //TODO: Is this if statement stupid? 
                pathData = normalCalculateMove(currentPlayer);
            }
        }
    }else{
        //TODO: Does this actually do anything?
    }
    return pathData;

}

Aucun commentaire:

Enregistrer un commentaire