Merge remote-tracking branch 'origin/main'

This commit is contained in:
schrom01 2021-12-10 22:36:56 +01:00
commit 9f9a1e872d
1 changed files with 25 additions and 24 deletions

View File

@ -17,28 +17,29 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
/** /**
* @class SiedlerGameTest * SiedlerGameTest Class
* <p> *
* contains all of the test cases for SiedlerGame class. * contains all 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
* @author Michael Ziegler
*/ */
public class SiedlerGameTest { public class SiedlerGameTest {
private final static int DEFAULT_WINPOINTS = 5; private final static int DEFAULT_WINPOINTS = 5;
private final static int DEFAULT_PLAYERAMOUNT = 4; private final static int DEFAULT_PLAYER_AMOUNT = 4;
/** /**
* 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
*/ */
@ -51,7 +52,7 @@ public class SiedlerGameTest {
/** /**
* 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
*/ */
@ -80,7 +81,7 @@ public class SiedlerGameTest {
@ParameterizedTest(name = "Test with {arguments} players") @ParameterizedTest(name = "Test with {arguments} players")
@ValueSource(ints = {2, 3, 4}) @ValueSource(ints = {2, 3, 4})
@DisplayName("Game initializing with different amount of players within the domain (Players have no resources), expected ok") @DisplayName("Game initializing with different amount of players within the domain (Players have no resources), expected ok")
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()) {
@ -99,10 +100,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
@ -127,8 +128,8 @@ public class SiedlerGameTest {
} }
/** /**
* @Class NegAtiveTestcases * NegativeTestcases
* <p> *
* contains all negative test cases * contains all negative test cases
*/ */
@Nested @Nested
@ -136,14 +137,14 @@ public class SiedlerGameTest {
class NegativeTestcases { class NegativeTestcases {
/** /**
* Tests if siedlergame will start with one or five players. * Tests if siedler game will start with one or five players.
* 1 Player is below the minimum * 1 Player is below the minimum
* 5 Players are above the maximum * 5 Players are above the maximum
*/ */
@ParameterizedTest(name = "Test with {arguments} players") @ParameterizedTest(name = "Test with {arguments} players")
@ValueSource(ints = {1, 5}) @ValueSource(ints = {1, 5})
@DisplayName("Starting Siedler game with one player or 5 players, expects fail") @DisplayName("Starting Siedler game with one player or 5 players, expects fail")
public void startSiedlerGameWithOnePlayerorMoreThanMaximum(int playerAmount) { public void startSiedlerGameWithOnePlayErrorMoreThanMaximum(int playerAmount) {
Exception exc = assertThrows(IllegalArgumentException.class, () -> { Exception exc = assertThrows(IllegalArgumentException.class, () -> {
new SiedlerGame(DEFAULT_WINPOINTS, playerAmount); new SiedlerGame(DEFAULT_WINPOINTS, playerAmount);
}); });
@ -166,9 +167,9 @@ 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 overwriting
* 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
@ -196,8 +197,8 @@ public class SiedlerGameTest {
} }
/** /**
* @Class SystemTestCases * 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
@ -205,7 +206,7 @@ public class SiedlerGameTest {
class SystemTestcases { class SystemTestcases {
/** /**
* TestS if the players can place initial settlements and roads * Tests if the players can place initial settlements and roads
*/ */
@Test @Test
@DisplayName("2 Players initialize a settlement and position") @DisplayName("2 Players initialize a settlement and position")
@ -225,7 +226,7 @@ public class SiedlerGameTest {
} }
/** /**
* tests, if the players can do all pf the actions in the building phase * Tests, if the players can do all the actions in the building phase.
*/ */
@Test @Test
public void TestGameAfterSetupPhase() { public void TestGameAfterSetupPhase() {
@ -242,10 +243,10 @@ public class SiedlerGameTest {
/** /**
* Initializes a game with the default values of winning points and amount of player * Initializes a game with the default values of winning points and amount of player
* *
* @return * @return SiedlerGame that was created with default winpoints and default player amount.
*/ */
private static SiedlerGame startGame() { private static SiedlerGame startGame() {
return new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT); return new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYER_AMOUNT);
} }
/** /**
@ -279,7 +280,7 @@ 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