move = new ChangeTrackPieceMove(oldTrackPiece, oldTrackPiece, new Point(0, 0), testPlayer.getPrincipal()); moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal()); assertNotNull(moveStatus); assertEquals(false, moveStatus.isOk());
boolean failed = false; try { move = new ChangeTrackPieceMove(oldTrackPiece, oldTrackPiece, new Point(0, 0), testPlayer.getPrincipal()); } catch (IllegalArgumentException e) { failed = true; } assertTrue(failed);
    public void testTryDoMove() {        setUp();        TrackTile oldTrackPiece;        TrackTile newTrackPiece;        byte oldConfig;        byte newConfig;        TrackMove move;        MoveStatus moveStatus;        //Try building the simplest piece of track.        newConfig = CompassPoints.NORTH;	FreerailsTile ft = getWorld().getTile(0, 0);	ft.setOwner(testPlayer.getPrincipal());        oldTrackPiece = ft.getTrackTile();        newTrackPiece = TrackTile.createTrackTile(getWorld(), newConfig, 0);        move = new ChangeTrackPieceMove(oldTrackPiece, newTrackPiece,                new Point(0, 0), testPlayer.getPrincipal());        moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal());        assertNotNull(moveStatus);        assertEquals(true, moveStatus.isOk());        //As above but with newTrackPiece and oldTrackPiece in the wrong order, should fail.        move = new ChangeTrackPieceMove(newTrackPiece, oldTrackPiece,                new Point(0, 0), testPlayer.getPrincipal());        moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal());        assertNotNull(moveStatus);        assertEquals(false, moveStatus.isOk());        //Try a move that does nothing, i.e. oldTrackPiece==newTrackPiece, should fail.        move = new ChangeTrackPieceMove(oldTrackPiece, oldTrackPiece,                new Point(0, 0), testPlayer.getPrincipal());        moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal());        assertNotNull(moveStatus);        assertEquals(false, moveStatus.isOk());        //Try buildingtrack outside the map.        move = new ChangeTrackPieceMove(newTrackPiece, oldTrackPiece,                new Point(100, 0), testPlayer.getPrincipal());        moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal());        assertNotNull(moveStatus);        assertEquals(false, moveStatus.isOk());        //Try building an illegal track configuration.	newConfig = CompassPoints.SOUTHEAST | CompassPoints.SOUTH |	    CompassPoints.SOUTHWEST | CompassPoints.WEST;        newTrackPiece = TrackTile.createTrackTile(getWorld(), newConfig, 0);        move = new ChangeTrackPieceMove(oldTrackPiece, newTrackPiece,                new Point(0, 0), testPlayer.getPrincipal());        moveStatus = move.tryDoMove(getWorld(), testPlayer.getPrincipal());        assertEquals(false, moveStatus.isOk());    }