mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 02:19:45 +01:00
T001 - T034 erster versuch
This commit is contained in:
parent
232e3a117c
commit
c792a8b3fb
@ -0,0 +1,385 @@
|
|||||||
|
package pp.monopoly;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
public class Testhandbuch {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// T001 UC-game-01 - testStartApplication
|
||||||
|
@Test
|
||||||
|
public void testStartApplication() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
assertNotNull(mainMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T002 UC-game-02 - testOpenStartMenu
|
||||||
|
@Test
|
||||||
|
public void testOpenStartMenu() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
mainMenu.showMenu();
|
||||||
|
assertTrue(mainMenu.isMenuVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T003 UC-game-03 - testNavigateToPlayOption
|
||||||
|
@Test
|
||||||
|
public void testNavigateToPlayOption() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
mainMenu.showMenu();
|
||||||
|
mainMenu.startNewGame();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
assertNotNull(newGameMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T004 UC-game-04 - testExitApplicationFromMenu
|
||||||
|
@Test
|
||||||
|
public void testExitApplicationFromMenu() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
mainMenu.showMenu();
|
||||||
|
mainMenu.exitGame();
|
||||||
|
assertTrue(app.isClosed());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T005 UC-game-05 - testOpenSettingsFromMenu
|
||||||
|
@Test
|
||||||
|
public void testOpenSettingsFromMenu() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
mainMenu.showMenu();
|
||||||
|
mainMenu.openSettings();
|
||||||
|
SettingMenu settingMenu = app.getStateManager().getState(SettingMenu.class);
|
||||||
|
assertNotNull(settingMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T006 UC-game-06 - testOpenGameMenuWithESC
|
||||||
|
@Test
|
||||||
|
public void testOpenGameMenuWithESC() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
app.simpleUpdate(0.1f);
|
||||||
|
GameMenu gameMenu = app.getStateManager().getState(GameMenu.class);
|
||||||
|
assertTrue(gameMenu.isVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T007 UC-game-07 - testEnterHostName
|
||||||
|
@Test
|
||||||
|
public void testEnterHostName() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.enterHostName("localhost");
|
||||||
|
assertEquals("localhost", newGameMenu.getHostName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T008 UC-game-07 - testEnterPortNumber
|
||||||
|
@Test
|
||||||
|
public void testEnterPortNumber() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.enterPortNumber(12345);
|
||||||
|
assertEquals(12345, newGameMenu.getPortNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T009 UC-game-07 - testCancelGameCreation
|
||||||
|
@Test
|
||||||
|
public void testCancelGameCreation() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.cancel();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
assertTrue(mainMenu.isMenuVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T010 UC-game-08 - testEnterPlayerLobby
|
||||||
|
@Test
|
||||||
|
public void testEnterPlayerLobby() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
app.getStateManager().getState(NetworkDialog.class).connect();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
assertNotNull(lobby);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T011 UC-game-09 - testEnterStartingCapital
|
||||||
|
@Test
|
||||||
|
public void testEnterStartingCapital() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.enterStartingCapital(1500);
|
||||||
|
assertEquals(1500, newGameMenu.getStartingCapital());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T012 UC-game-09 - testIncreaseStartingCapital
|
||||||
|
@Test
|
||||||
|
public void testIncreaseStartingCapital() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.enterStartingCapital(1500);
|
||||||
|
newGameMenu.increaseStartingCapital(100);
|
||||||
|
assertEquals(1600, newGameMenu.getStartingCapital());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T013 UC-game-09 - testDecreaseStartingCapital
|
||||||
|
@Test
|
||||||
|
public void testDecreaseStartingCapital() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
|
||||||
|
newGameMenu.showMenu();
|
||||||
|
newGameMenu.enterStartingCapital(1500);
|
||||||
|
newGameMenu.decreaseStartingCapital(100);
|
||||||
|
assertEquals(1400, newGameMenu.getStartingCapital());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T014 UC-game-10 - testDefaultPlayerName
|
||||||
|
@Test
|
||||||
|
public void testDefaultPlayerName() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
app.getStateManager().getState(Lobby.class).initializePlayerNames();
|
||||||
|
assertEquals("Spieler 1", app.getStateManager().getState(Lobby.class).getPlayerName(0));
|
||||||
|
assertEquals("Spieler 2", app.getStateManager().getState(Lobby.class).getPlayerName(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T015 UC-game-11 - testEnterDisplayName
|
||||||
|
@Test
|
||||||
|
public void testEnterDisplayName() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.enterDisplayName("TestPlayer");
|
||||||
|
assertEquals("TestPlayer", lobby.getPlayerName(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T016 UC-game-11 - testDuplicateNameEntry
|
||||||
|
@Test
|
||||||
|
public void testDuplicateNameEntry() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.enterDisplayName("Player1");
|
||||||
|
assertTrue(lobby.isDuplicateName("Player1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T017 UC-game-12 - testSelectPlayerColor
|
||||||
|
@Test
|
||||||
|
public void testSelectPlayerColor() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.selectColor("Red");
|
||||||
|
assertEquals("Red", lobby.getPlayerColor(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T018 UC-game-12 - testSelectOccupiedColor
|
||||||
|
@Test
|
||||||
|
public void testSelectOccupiedColor() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.selectColor("Red");
|
||||||
|
assertTrue(lobby.isColorOccupied("Red"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T019 UC-game-13 - testSelectPlayerToken
|
||||||
|
@Test
|
||||||
|
public void testSelectPlayerToken() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.selectToken("Ship");
|
||||||
|
assertEquals("Ship", lobby.getPlayerToken(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T020 UC-game-13 - testSelectOccupiedToken
|
||||||
|
@Test
|
||||||
|
public void testSelectOccupiedToken() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.selectToken("Ship");
|
||||||
|
assertTrue(lobby.isTokenOccupied("Ship"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T021 UC-game-14 - testCancelPlayerLobby
|
||||||
|
@Test
|
||||||
|
public void testCancelPlayerLobby() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.cancel();
|
||||||
|
MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
|
||||||
|
assertTrue(mainMenu.isMenuVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T022 UC-game-15 - testOpenLobbyMenuWithESC
|
||||||
|
@Test
|
||||||
|
public void testOpenLobbyMenuWithESC() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
app.simpleUpdate(0.1f);
|
||||||
|
LobbyMenu lobbyMenu = app.getStateManager().getState(LobbyMenu.class);
|
||||||
|
assertTrue(lobbyMenu.isVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T023 UC-game-16 - testPlayerReadyConfirmation
|
||||||
|
@Test
|
||||||
|
public void testPlayerReadyConfirmation() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.setPlayerReady(true);
|
||||||
|
assertTrue(lobby.isPlayerReady(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T024 UC-game-17 - testStartGame
|
||||||
|
@Test
|
||||||
|
public void testStartGame() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Lobby lobby = app.getStateManager().getState(Lobby.class);
|
||||||
|
lobby.startGame();
|
||||||
|
assertEquals(GameState.InGame, lobby.getGameState());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T025 UC-game-18 - testPlayerMovement
|
||||||
|
@Test
|
||||||
|
public void testPlayerMovement() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
player.move(5);
|
||||||
|
assertEquals(5, player.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T026 UC-game-19 - testPurchaseProperty
|
||||||
|
@Test
|
||||||
|
public void testPurchaseProperty() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
Property property = game.getProperty(0);
|
||||||
|
player.buyProperty(property);
|
||||||
|
assertTrue(player.getProperties().contains(property));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T027 UC-game-20 - testMovePlayerOnDiceRoll
|
||||||
|
@Test
|
||||||
|
public void testMovePlayerOnDiceRoll() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
int initialPosition = player.getPosition();
|
||||||
|
player.rollDice();
|
||||||
|
assertTrue(player.getPosition() > initialPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T028 UC-game-21 - testPassGo
|
||||||
|
@Test
|
||||||
|
public void testPassGo() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
player.move(40); // Assuming 40 steps moves player to Go
|
||||||
|
assertTrue(player.passedGo());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T029 UC-game-22 - testCollectMoneyFromGo
|
||||||
|
@Test
|
||||||
|
public void testCollectMoneyFromGo() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
int initialBalance = player.getBalance();
|
||||||
|
player.move(40); // Move to Go
|
||||||
|
assertTrue(player.getBalance() > initialBalance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T030 UC-game-23 - testPayRent
|
||||||
|
@Test
|
||||||
|
public void testPayRent() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
PropertyField property = (PropertyField) game.getField(1);
|
||||||
|
player.move(1);
|
||||||
|
int initialBalance = player.getBalance();
|
||||||
|
player.payRent(property);
|
||||||
|
assertTrue(player.getBalance() < initialBalance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// T031 UC-game-24 - testDeclareBankruptcy
|
||||||
|
@Test
|
||||||
|
public void testDeclareBankruptcy() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
player.declareBankruptcy();
|
||||||
|
assertEquals(PlayerState.Bankrupt, player.getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T032 UC-game-25 - testTradeProperty
|
||||||
|
@Test
|
||||||
|
public void testTradeProperty() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player1 = game.getPlayer(0);
|
||||||
|
Player player2 = game.getPlayer(1);
|
||||||
|
Property property = game.getProperty(0);
|
||||||
|
player1.offerTrade(player2, property);
|
||||||
|
assertTrue(player2.hasProperty(property));
|
||||||
|
}
|
||||||
|
|
||||||
|
// T033 UC-game-26 - testGameOverCondition
|
||||||
|
@Test
|
||||||
|
public void testGameOverCondition() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
player.declareBankruptcy();
|
||||||
|
assertTrue(game.isGameOver());
|
||||||
|
}
|
||||||
|
|
||||||
|
// T034 UC-game-27 - testPlayerInJail
|
||||||
|
@Test
|
||||||
|
public void testPlayerInJail() {
|
||||||
|
MonopolyApp app = new MonopolyApp();
|
||||||
|
app.simpleInitApp();
|
||||||
|
Game game = app.getStateManager().getState(Game.class);
|
||||||
|
Player player = game.getPlayer(0);
|
||||||
|
game.sendToJail(player);
|
||||||
|
assertEquals(PlayerState.InJail, player.getState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user