quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java
changeset 75 6802034b7a6f
parent 40 e45bc8ad2eaf
child 92 de3dd5710a5c
     1.1 --- a/quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java	Wed Jul 29 21:35:04 2009 +0200
     1.2 +++ b/quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java	Thu Sep 10 23:19:40 2009 +0200
     1.3 @@ -51,6 +51,32 @@
     1.4      protected abstract Board apply(Board b, Move move) throws IllegalPositionException;
     1.5  
     1.6  
     1.7 +    public void testResignWhite() throws IllegalPositionException {
     1.8 +        List<Player> list = board.getPlayers();
     1.9 +        assertEquals ("Two", 2, list.size ());
    1.10 +        Board b = board.apply(Move.RESIGN);
    1.11 +        assertEquals(b.getPlayers().get(1), b.getWinner());
    1.12 +        try {
    1.13 +            b.apply(Move.EAST);
    1.14 +            fail("No more moves allowed, the player resigned");
    1.15 +        } catch (IllegalPositionException ex) {
    1.16 +            // OK
    1.17 +        }
    1.18 +        assertNull("No player", b.getCurrentPlayer());
    1.19 +    }
    1.20 +    public void testResignBlack() throws IllegalPositionException {
    1.21 +        List<Player> list = board.getPlayers();
    1.22 +        assertEquals ("Two", 2, list.size ());
    1.23 +        Board b = board.apply(Move.NORTH).apply(Move.RESIGN);
    1.24 +        assertEquals(b.getPlayers().get(0), b.getWinner());
    1.25 +        try {
    1.26 +            b.apply(Move.EAST);
    1.27 +            fail("No more moves allowed, the player resigned");
    1.28 +        } catch (IllegalPositionException ex) {
    1.29 +            // OK
    1.30 +        }
    1.31 +        assertNull("No player", b.getCurrentPlayer());
    1.32 +    }
    1.33      public void testTwoPlayers () {
    1.34          List<Player> list = board.getPlayers();
    1.35          assertEquals ("Two", 2, list.size ());