@Test public void test_processGameFinished_haveTiles() throws Exception { final Dictionary dictionary = createDictionary(); final TilesBank tilesBank = new TilesBank(editor.createTilesBankInfo()); final ScribbleBoard board = new ScribbleBoard( settings, Arrays.asList(player1, player2, player3), tilesBank, dictionary); h1 = board.getPlayerHand(player1); h2 = board.getPlayerHand(player2); h3 = board.getPlayerHand(player3); h1.setTiles(tilesBank.getTiles(0, 3, 6, 9)); // abcd: 10 points - should be winner h2.setTiles(tilesBank.getTiles(9, 12, 15, 18)); // defg: 22 points h3.setTiles(tilesBank.getTiles(16, 17, 19, 20)); // ffgg: 26 points // we need increate player points to make it winner. final Method method = h3.getClass().getSuperclass().getDeclaredMethod("increasePoints", short.class); method.setAccessible(true); method.invoke(h3, (short) 1); // Player h3 has 1 points and other have 0 points. short[] ints = board.processGameFinished(); assertEquals(3, ints.length); assertEquals(-10, ints[0]); // final points for h1: looser assertEquals(-22, ints[1]); // final points for h2: looser assertEquals(-26, ints[2]); // final points for h3: winned }
@Test public void test_processGameFinished_noTiles() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { final Dictionary dictionary = createDictionary(); final TilesBank tilesBank = new TilesBank(editor.createTilesBankInfo()); final ScribbleBoard board = new ScribbleBoard( settings, Arrays.asList(player1, player2, player3), tilesBank, dictionary); h1 = board.getPlayerHand(player1); h2 = board.getPlayerHand(player2); h3 = board.getPlayerHand(player3); h1.setTiles(tilesBank.getTiles(0, 3, 6, 9)); // abcd: 10 points h2.setTiles(tilesBank.getTiles(9, 12, 15, 18)); // defg: 22 points h3.setTiles(new Tile[0]); // winner short[] ints = board.processGameFinished(); assertEquals(3, ints.length); assertEquals(-10, ints[0]); // final points for h1: looser assertEquals(-22, ints[1]); // final points for h2: looser assertEquals(32, ints[2]); // final points for h3: winned }