package com.adaptionsoft.games.uglytrivia;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

import static junitparams.JUnitParamsRunner.$;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

@RunWith(JUnitParamsRunner.class)
public class QuestionsTest {

    private Questions questions = new Questions();

    @Test(expected = IllegalArgumentException.class)
    public void shouldFailOnUnknownCategory() {
        questions.nextFor("unknown category");
    }

    @Test
    @Parameters(method = "categoriesAndQuestions")
    public void shouldAskQuestion(String category, String question) {
        assertThat(questions.nextFor(category), is(question));
    }

    @Test
    public void shouldAskDifferentPopQuestionOnSecondCall() {
        questions.nextFor("Pop");

        assertThat(questions.nextFor("Pop"), is("Pop Question 1"));
    }

    @SuppressWarnings("unused")
    private Object[] categoriesAndQuestions() {
        return $($("Pop", "Pop Question 0"),
                $("Science", "Science Question 0"),
                $("Sports", "Sports Question 0"),
                $("Rock", "Rock Question 0"));
    }

    @Test
    public void shouldAskDifferentQuestionOnSecondCall() {
        fail("add test that the 4 categories do not ask same question twice");
    }
}

@@ -300,45 +300,8 @@
 hat;
-%0Aimport static org.junit.Assert.fail;
 %0A%0A@R
@@ -774,190 +774,8 @@
  %7D%0A%0A
-    @Test%0A    public void shouldAskDifferentPopQuestionOnSecondCall() %7B%0A        questions.nextFor(%22Pop%22);%0A%0A        assertThat(questions.nextFor(%22Pop%22), is(%22Pop Question 1%22));%0A    %7D%0A%0A
     
@@ -1069,139 +1069,537 @@
     
-public void shouldAskDifferentQuestionOnSecondCall() %7B%0A        fail(%22add test that the 4 categories do not ask same question twice%22
+@Parameters(method = %22categoriesAndSecondQuestions%22)%0A    public void shouldAskDifferentQuestionOnSecondCall(String category, String question) %7B%0A        questions.nextFor(category);%0A%0A        assertThat(questions.nextFor(category), is(question));%0A    %7D%0A%0A    @SuppressWarnings(%22unused%22)%0A    private Object%5B%5D categoriesAndSecondQuestions() %7B%0A        return $($(%22Pop%22, %22Pop Question 1%22),%0A                $(%22Science%22, %22Science Question 1%22),%0A                $(%22Sports%22, %22Sports Question 1%22),%0A                $(%22Rock%22, %22Rock Question 1%22)
 );%0A 
@@ -1603,10 +1603,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

test second question is different from first question