package org.mkonrad.fizzbuzz;

import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;

import java.io.PrintStream;
import java.util.stream.Stream;

import static org.mockito.Mockito.*;

/**
 * @author Markus Konrad
 */
public class FizzBuzzTest {

  public static final String[] EXPECTED_OUTPUT = {
    "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz",
    "11", "Fizz", "13", "14", "FizzBuzz", "16", "17", "Fizz", "19", "Buzz",
    "Fizz", "22", "23", "Fizz", "Buzz", "26", "Fizz", "28", "29", "FizzBuzz",
    "31", "32", "Fizz", "34", "Buzz", "Fizz", "37", "38", "Fizz", "Buzz",
    "41", "Fizz", "43", "44", "FizzBuzz", "46", "47", "Fizz", "49", "Buzz",
    "Fizz", "52", "53", "Fizz", "Buzz", "56", "Fizz", "58", "59", "FizzBuzz",
    "61", "62", "Fizz", "64", "Buzz", "Fizz", "67", "68", "Fizz", "Buzz",
    "71", "Fizz", "73", "74", "FizzBuzz", "76", "77", "Fizz", "79", "Buzz",
    "Fizz", "82", "83", "Fizz", "Buzz", "86", "Fizz", "88", "89", "FizzBuzz",
    "91", "92", "Fizz", "94", "Buzz", "Fizz", "97", "98", "Fizz", "Buzz"
  };

	private PrintStream printStream;
	private FizzBuzz fizzBuzz;

	@Before
	public void setUp() throws Exception {
		printStream = mock(PrintStream.class);
		fizzBuzz = new FizzBuzz(printStream);
	}

	@Test
	public void run_numberOfRoundsIsNegative_printHint() throws Exception {
		// given
		int numberOfRounds = -1;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
		verify(printStream).println("Please specify a positive value for the parameter \"numberOfRounds\"");
		verifyNoMoreInteractions(printStream);
	}

	@Test
	public void run_numberOfRoundsIsZero_printHint() throws Exception {
		// given
		int numberOfRounds = 0;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
		verify(printStream).println("Please specify a positive value for the parameter \"numberOfRounds\"");
		verifyNoMoreInteractions(printStream);
	}

	@Test
	public void run_oneRound() throws Exception {
		// given
		int numberOfRounds = 1;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
    InOrder inOrder = inOrder(printStream);
    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -> inOrder.verify(printStream).println(x));
    verifyNoMoreInteractions(printStream);
	}

	@Test
	public void run_threeRounds() throws Exception {
		// given
		int numberOfRounds = 3;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
		InOrder inOrder = inOrder(printStream);
    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -> inOrder.verify(printStream).println(x));
    verify(printStream, times(numberOfRounds)).println(anyString());
	}

	@Test
	public void run_fiveRounds() throws Exception {
		// given
		int numberOfRounds = 5;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
		InOrder inOrder = inOrder(printStream);
    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -> inOrder.verify(printStream).println(x));
    verify(printStream, times(numberOfRounds)).println(anyString());
	}

	@Test
	public void run_fifteenRounds() throws Exception {
		// given
		int numberOfRounds = 15;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
		InOrder inOrder = inOrder(printStream);
    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -> inOrder.verify(printStream).println(x));
    verify(printStream, times(numberOfRounds)).println(anyString());
	}

	@Test
	public void run_oneHundredRounds() throws Exception {
		// given
		int numberOfRounds = 100;
		// when
		fizzBuzz.run(numberOfRounds);
		// then
    InOrder inOrder = inOrder(printStream);
    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -> inOrder.verify(printStream).println(x));
    verify(printStream, times(numberOfRounds)).println(anyString());
	}
}

@@ -1903,1455 +1903,8 @@
 %09%7D%0A%0A
-%09@Test%0A%09public void run_oneRound() throws Exception %7B%0A%09%09// given%0A%09%09int numberOfRounds = 1;%0A%09%09// when%0A%09%09fizzBuzz.run(numberOfRounds);%0A%09%09// then%0A    InOrder inOrder = inOrder(printStream);%0A    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -%3E inOrder.verify(printStream).println(x));%0A    verifyNoMoreInteractions(printStream);%0A%09%7D%0A%0A%09@Test%0A%09public void run_threeRounds() throws Exception %7B%0A%09%09// given%0A%09%09int numberOfRounds = 3;%0A%09%09// when%0A%09%09fizzBuzz.run(numberOfRounds);%0A%09%09// then%0A%09%09InOrder inOrder = inOrder(printStream);%0A    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -%3E inOrder.verify(printStream).println(x));%0A    verify(printStream, times(numberOfRounds)).println(anyString());%0A%09%7D%0A%0A%09@Test%0A%09public void run_fiveRounds() throws Exception %7B%0A%09%09// given%0A%09%09int numberOfRounds = 5;%0A%09%09// when%0A%09%09fizzBuzz.run(numberOfRounds);%0A%09%09// then%0A%09%09InOrder inOrder = inOrder(printStream);%0A    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -%3E inOrder.verify(printStream).println(x));%0A    verify(printStream, times(numberOfRounds)).println(anyString());%0A%09%7D%0A%0A%09@Test%0A%09public void run_fifteenRounds() throws Exception %7B%0A%09%09// given%0A%09%09int numberOfRounds = 15;%0A%09%09// when%0A%09%09fizzBuzz.run(numberOfRounds);%0A%09%09// then%0A%09%09InOrder inOrder = inOrder(printStream);%0A    Stream.of(EXPECTED_OUTPUT).limit(numberOfRounds).forEach(x -%3E inOrder.verify(printStream).println(x));%0A    verify(printStream, times(numberOfRounds)).println(anyString());%0A%09%7D%0A%0A
 %09@Te

Remove redundant test methods