// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }


import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

        ArgumentCaptor<EventListener> argument = ArgumentCaptor.forClass(EventListener.class);
        verify(view).whenPreviousQuestionRequested(argument.capture());
        argument.getValue().onDispatch();

        verify(model).gotoPreviousQuestion();
    }

    @Test
    public void updatesViewWithNewQuestionText_whenModelChanges() {
        model = mock(QuestionModel.class);
        when(model.getQuestionText()).thenReturn("question1", "question2");
        view = mock(QuestionView.class);
        new QuestionPresenter(view, model);

        ArgumentCaptor<EventListener> argument = ArgumentCaptor.forClass(EventListener.class);
        verify(model).whenQuestionTextChanged(argument.capture());
        argument.getValue().onDispatch();

        verify(view).setQuestionText("question2");
    }

    private void makePresenterWithModelAnswer(boolean answer, boolean isCorrectAnswer) {
        model = mock(QuestionModel.class);
        when(model.isCorrectAnswer(answer)).thenReturn(isCorrectAnswer);
        view = mock(QuestionView.class);
        new QuestionPresenter(view, model);
    }

    private void simulateUserAnswer(boolean answer) {
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }


// Path: chapter2-geoquiz-challenges/app/src/test/java/com/olerass/pfexample/android/geoquiz/domain/question/QuestionPresenterTest.java
import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


        ArgumentCaptor<EventListener> argument = ArgumentCaptor.forClass(EventListener.class);
        verify(view).whenPreviousQuestionRequested(argument.capture());
        argument.getValue().onDispatch();

        verify(model).gotoPreviousQuestion();
    }

    @Test
    public void updatesViewWithNewQuestionText_whenModelChanges() {
        model = mock(QuestionModel.class);
        when(model.getQuestionText()).thenReturn("question1", "question2");
        view = mock(QuestionView.class);
        new QuestionPresenter(view, model);

        ArgumentCaptor<EventListener> argument = ArgumentCaptor.forClass(EventListener.class);
        verify(model).whenQuestionTextChanged(argument.capture());
        argument.getValue().onDispatch();

        verify(view).setQuestionText("question2");
    }

    private void makePresenterWithModelAnswer(boolean answer, boolean isCorrectAnswer) {
        model = mock(QuestionModel.class);
        when(model.isCorrectAnswer(answer)).thenReturn(isCorrectAnswer);
        view = mock(QuestionView.class);
        new QuestionPresenter(view, model);
    }

    private void simulateUserAnswer(boolean answer) {
        ArgumentCaptor<DataEventListener<Boolean>> argument = ArgumentCaptor.forClass((Class)DataEventListener.class);