reformat Code in SiedlerGameTest
This commit is contained in:
parent
1bdbc80c06
commit
57e49db1f0
|
@ -1,30 +1,35 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Point;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class SiedlerGameTest
|
* @class SiedlerGameTest
|
||||||
*
|
* <p>
|
||||||
* contains all of the test cases for SiedlerGame class.
|
* contains all of the test cases for SiedlerGame class.
|
||||||
* The Test cases are categorized into
|
* The Test cases are categorized into
|
||||||
* - Positive TestCases
|
* - Positive TestCases
|
||||||
* Tests the methods of SiedlerGame with the intended values
|
* Tests the methods of SiedlerGame with the intended values
|
||||||
*
|
* <p>
|
||||||
* - Negative TestCases
|
* - Negative TestCases
|
||||||
* Tests the methods of SiedlerGame with values, that results to errors and failure
|
* Tests the methods of SiedlerGame with values, that results to errors and failure
|
||||||
*
|
* <p>
|
||||||
* - SystemTestCases
|
* - SystemTestCases
|
||||||
* Tests the coordination of all methods and simulates a game with programmed moves
|
* Tests the coordination of all methods and simulates a game with programmed moves
|
||||||
* Checks if the methods are being executed and the values are set correctly
|
* Checks if the methods are being executed and the values are set correctly
|
||||||
*/
|
*/
|
||||||
public class SiedlerGameTest {
|
public class SiedlerGameTest {
|
||||||
|
|
||||||
|
@ -33,20 +38,20 @@ public class SiedlerGameTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property START_SETTLEMENT_POSITIONS
|
* Property START_SETTLEMENT_POSITIONS
|
||||||
*
|
* <p>
|
||||||
* Lists all positions of Settlement for every faction in the initialization phase.
|
* Lists all positions of Settlement for every faction in the initialization phase.
|
||||||
* Each faction is assigned to a list of specific settlements, which represents as a list of points
|
* Each faction is assigned to a list of specific settlements, which represents as a list of points
|
||||||
*/
|
*/
|
||||||
private final static Map<Config.Faction, ArrayList<Point>> START_SETTLEMENT_POSITIONS = Map.of(
|
private final static Map<Config.Faction, ArrayList<Point>> START_SETTLEMENT_POSITIONS = Map.of(
|
||||||
Config.Faction.BLUE, new ArrayList<>(List.of(new Point(4, 4), new Point(5, 7))),
|
Config.Faction.BLUE, new ArrayList<>(List.of(new Point(4, 4), new Point(5, 7))),
|
||||||
Config.Faction.RED, new ArrayList<>(List.of(new Point(10, 4), new Point(9, 7))),
|
Config.Faction.RED, new ArrayList<>(List.of(new Point(10, 4), new Point(9, 7))),
|
||||||
Config.Faction.GREEN, new ArrayList<>(List.of(new Point(4, 18), new Point(5, 15))),
|
Config.Faction.GREEN, new ArrayList<>(List.of(new Point(4, 18), new Point(5, 15))),
|
||||||
Config.Faction.YELLOW, new ArrayList<>(List.of(new Point(10, 18), new Point(9, 15)))
|
Config.Faction.YELLOW, new ArrayList<>(List.of(new Point(10, 18), new Point(9, 15)))
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property START_ROADS_POSITION
|
* Property START_ROADS_POSITION
|
||||||
*
|
* <p>
|
||||||
* Lists all endpoints of roads for every faction in the initialization phase.
|
* Lists all endpoints of roads for every faction in the initialization phase.
|
||||||
* Each faction is assigned to a specific Road, which represents as a tuple of 2 points
|
* Each faction is assigned to a specific Road, which represents as a tuple of 2 points
|
||||||
*/
|
*/
|
||||||
|
@ -78,7 +83,7 @@ public class SiedlerGameTest {
|
||||||
public void TestGameInitializationWithAllPlayercounts(int playerAmount) {
|
public void TestGameInitializationWithAllPlayercounts(int playerAmount) {
|
||||||
SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, playerAmount);
|
SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, playerAmount);
|
||||||
|
|
||||||
for (Config.Faction faction: game.getPlayerFactions()) {
|
for (Config.Faction faction : game.getPlayerFactions()) {
|
||||||
HashMap<Config.Resource, Integer> resources = game.getCurrentPlayerResource();
|
HashMap<Config.Resource, Integer> resources = game.getCurrentPlayerResource();
|
||||||
|
|
||||||
Assertions.assertEquals(0, resources.get(Config.Resource.BRICK));
|
Assertions.assertEquals(0, resources.get(Config.Resource.BRICK));
|
||||||
|
@ -94,10 +99,10 @@ public class SiedlerGameTest {
|
||||||
/**
|
/**
|
||||||
* Tests if the method throwDice halves the resources of the player
|
* Tests if the method throwDice halves the resources of the player
|
||||||
* 7 will be passed to the throwDice Method when called
|
* 7 will be passed to the throwDice Method when called
|
||||||
*
|
* <p>
|
||||||
* Method does not halve a resource, when the amount is below 7.
|
* Method does not halve a resource, when the amount is below 7.
|
||||||
* Player has gotten 8 wool resources and throws a 7 with the dice
|
* Player has gotten 8 wool resources and throws a 7 with the dice
|
||||||
*
|
* <p>
|
||||||
* expected: throwDice with a 7 will halve wool resource, the amount should be 4
|
* expected: throwDice with a 7 will halve wool resource, the amount should be 4
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@ -123,7 +128,7 @@ public class SiedlerGameTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Class NegAtiveTestcases
|
* @Class NegAtiveTestcases
|
||||||
*
|
* <p>
|
||||||
* contains all negative test cases
|
* contains all negative test cases
|
||||||
*/
|
*/
|
||||||
@Nested
|
@Nested
|
||||||
|
@ -163,7 +168,7 @@ public class SiedlerGameTest {
|
||||||
/**
|
/**
|
||||||
* This testcase will test, if the methods placeInitialRoad and placeInitialSettlement are overwritting
|
* This testcase will test, if the methods placeInitialRoad and placeInitialSettlement are overwritting
|
||||||
* already occupied positions if the same faction or any other faction are calling the method with the same positions
|
* already occupied positions if the same faction or any other faction are calling the method with the same positions
|
||||||
*
|
* <p>
|
||||||
* Expected: Method placeInitialRoad placeInitialSettlement should return false, independent of the current faction playing
|
* Expected: Method placeInitialRoad placeInitialSettlement should return false, independent of the current faction playing
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@ -192,7 +197,7 @@ public class SiedlerGameTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Class SystemTestCases
|
* @Class SystemTestCases
|
||||||
*
|
* <p>
|
||||||
* This class simulates a running game and tests multiple sequences of this game.
|
* This class simulates a running game and tests multiple sequences of this game.
|
||||||
*/
|
*/
|
||||||
@Nested
|
@Nested
|
||||||
|
@ -276,9 +281,9 @@ public class SiedlerGameTest {
|
||||||
/**
|
/**
|
||||||
* This method will call the method "throwDice" multiple times and passes the set value of the dice
|
* This method will call the method "throwDice" multiple times and passes the set value of the dice
|
||||||
*
|
*
|
||||||
* @param game Type SiedlerGame, the game itself in a running state
|
* @param game Type SiedlerGame, the game itself in a running state
|
||||||
* @param dice Type int, Set Value of dice
|
* @param dice Type int, Set Value of dice
|
||||||
* @param amountDiceThrows Type int, The amount of dice throws
|
* @param amountDiceThrows Type int, The amount of dice throws
|
||||||
*/
|
*/
|
||||||
private static void throwDiceSeveralTimes(SiedlerGame game, int dice, int amountDiceThrows) {
|
private static void throwDiceSeveralTimes(SiedlerGame game, int dice, int amountDiceThrows) {
|
||||||
for (int i = 0; i < amountDiceThrows; i++) {
|
for (int i = 0; i < amountDiceThrows; i++) {
|
||||||
|
|
Loading…
Reference in New Issue