package com.adaptionsoft.games.uglytrivia;

import org.junit.Test;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;

public class GameTest {

    @Test
    public void wrongAnswerShouldSendPlayerToPenaltyBox() {
        Player lonelyTom = new Player("Lonely Tom");
        Game game = createGameWithSinglePlayer(lonelyTom);

        game.wrongAnswer();

        assertTrue("Player should be in penalty box", lonelyTom.isInPenaltyBox());
    }

    @Test
    public void wrongAnswerShouldNotGetACoin(){
        Player player = mock(Player.class);
        Game game = createGameWithSinglePlayer(player);

        game.wrongAnswer();

        verify(player, never()).answeredCorrect();
    }

    private Game createGameWithSinglePlayer(Player player) {
        Players players = new Players();
        players.add(player);
        return new Game(players, null);
    }

    @Test
    public void wrongAnswerShouldEndTurn(){
        Players players = mock(Players.class);
        Game game = new Game(players, null);

        game.wrongAnswer();

        verify(players).changeCurrentPlayer();
    }

        /*

        test output

        */
}

@@ -61,16 +61,165 @@
 .Test;%0A%0A
+import java.io.ByteArrayOutputStream;%0Aimport java.io.PrintStream;%0A%0Aimport static org.hamcrest.core.Is.is;%0Aimport static org.junit.Assert.assertThat;%0A
 import s
@@ -316,16 +316,49 @@
 Test %7B%0A%0A
+    private PrintStream sysOut;%0A%0A
     @Tes
@@ -707,16 +707,17 @@
 tACoin()
+ 
 %7B%0A      
@@ -1128,16 +1128,17 @@
 ndTurn()
+ 
 %7B%0A      
@@ -1315,46 +1315,755 @@
     
-    /*%0A%0A        test output%0A%0A        */
+@Test%0A    public void wrongAnswerShouldPrintAWrongAnswerMessage() %7B%0A        try %7B%0A            ByteArrayOutputStream systemOut = captureSystemOut();%0A%0A            Players players = mock(Players.class);%0A            Game game = new Game(players, null);%0A%0A            game.wrongAnswer();%0A%0A            assertThat(new String(systemOut.toByteArray()), is(%22Question was incorrectly answered%5Cn%22));%0A        %7D finally %7B%0A            resetSystemOut();%0A        %7D%0A    %7D%0A%0A    private ByteArrayOutputStream captureSystemOut() %7B%0A        sysOut = System.out;%0A%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        System.setOut(new PrintStream(out));%0A        return out;%0A    %7D%0A%0A    private void resetSystemOut() %7B%0A        System.setOut(sysOut);%0A    %7D
 %0A%7D%0A

Wrong answer should print a wrong answer message