@Test public void makeMoveWorksWithMoveChangesPlayer() { Move move = round.findMoves().get(0); round.makeMove(move.getY(), move.getX()); round.makeMove(move.getY2(), move.getX2()); assertEquals(false, round.isHumanTurn()); }
@Test public void makeMoveWorksWithMoveAfterMoveCancel() { round.makeMove(0, 0); round.makeMove(0, 0); Move move = round.findMoves().get(0); round.makeMove(move.getY(), move.getX()); assertEquals(true, round.makeMove(move.getY2(), move.getX2())); }
@Test(timeout = 4000) public void opponentReturnsTheTurn() { Move move = round.findMoves().get(0); round.makeMove(move.getY(), move.getX()); round.makeMove(move.getY2(), move.getX2()); while (round.makeMove(0, 0) == false) {} assertEquals(true, round.isHumanTurn()); }
@Test public void makeMoveDoesntWorkIfEarlierNotCancelled() { Move move = round.findMoves().get(0); int y = Math.max(size - 1, move.getY()); round.makeMove(y, 0); boolean test = round.makeMove(move.getY(), move.getX()); assertEquals(true, round.makeMove(move.getY2(), move.getX2()) == test); // makeMoven ei pitäisi palauttaa true kahdesti peräkkäin }
@Test public void abilityAvailableWhenYouLoaded() { round .getPlayer(0) .addToCollected( new int[] { 20, 20, 20, 20, 20, 20 }); assertEquals(true, round.useAbility(1)); }
@Test public void onlyListMovesAllowed() { List<Move> list = round.findMoves(); for (int i = 0; i < round.getBoardSize(); i++) { Move move = new Move(0, i, 1, i); if (!list.contains(move)) { assertEquals(false, round.switchPieces(move)); i = round.getBoardSize(); } } }
@Test public void noAbilitySpamEvenWhenYouLoaded() { round .getPlayer(0) .addToCollected( new int[] { 70, 0, 0, 0, 0, 0 }); round.useAbility(1); assertEquals(false, round.useAbility(1)); }
@Test(timeout = 1300) // Kestää pitkään, kun tekee paljon liikkeitä public void cannotExhaustMovesInOneSecond() { boolean moves = true; Calendar c = Calendar.getInstance(); c.add(Calendar.SECOND, 1); while (Calendar.getInstance().compareTo(c) < 0) { try { Move move = round.findMoves().get(0); round.switchPieces(move); } catch (Exception e) { moves = false; break; } } assertEquals(moves, true); }
@Test public void newBoardDoesSomething() { boolean test = false; try { round.getTypeAt(0, 0); test = true; } catch (Exception e) { } assertEquals(true, test); }
@Before public void setUp() { round = new GameRound(); round.newBoard(); size = round.getBoardSize(); }
@Test public void noAbilityUseWithoutResources() { assertEquals(false, round.useAbility(0)); }
@Test public void typesAreNotJustZeroes2() { assertEquals( true, round.getTypeAt(1, 0) != 0 || round.getTypeAt(1, 1) != 0 || round.getTypeAt(1, 2) != 0); }
@Test public void startWithHumanTurn() { assertEquals(true, round.isHumanTurn()); }
@Test public void movesWork3() { List<Move> list = round.findMoves(); assertEquals(round.switchPieces(list.get(Math.min(0, 2))), true); }
@Test public void twoPlayers() { assertEquals(false, round.getPlayer(1) == null); }
@Test public void typesAreNotJustOnes() { assertEquals( true, round.getTypeAt(0, 0) != 1 || round.getTypeAt(0, 1) != 1 || round.getTypeAt(0, 2) != 1); }
@Test public void noFarSwitch() { assertEquals(false, round.switchPieces(0, 0, size - 1, size - 1)); }
@Test public void movesNotNull() { assertEquals(false, round.findMoves() == null); }
@Test public void movesNotEmpty() { assertEquals(false, round.findMoves().isEmpty()); }