// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateLoader.java
// public interface StateLoader {
//     int loadInt(String key, int defaultIfNotFound);
//     boolean loadBool(String key, boolean defaultIfNotFound);
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateSaver.java
// public interface StateSaver {
//     void saveInt(String key, int value);
//     void saveBool(String key, boolean value);
// }


import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.state.StateLoader;
import com.olerass.pfexample.android.geoquiz.domain.state.StateSaver;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
        StandardCheatModel model = new StandardCheatModel("True");
        model.setAnswerShown(false);
        StateSaver stateSaver = mock(StateSaver.class);

        model.saveState(stateSaver);

        verify(stateSaver).saveBool("answerShown", false);
    }

    @Test
    public void loadState_loadsAnswerShown_whenCalled() {
        StandardCheatModel model = new StandardCheatModel("True");
        StateLoader stateLoader = mock(StateLoader.class);
        when(stateLoader.loadBool("answerShown", false)).thenReturn(true);

        model.loadState(stateLoader);
        boolean answerShown = model.isAnswerShown();

        assertEquals(true, answerShown);
    }

    @Test
    public void loadState_notifiesListenerThatAnswerShownChanged_whenLoadedValueIsDifferentFromCurrent() {
        StandardCheatModel model = new StandardCheatModel("True");
        model.setAnswerShown(false);
        EventListener listener = mock(EventListener.class);
        model.whenAnswerShownChanged(listener);
        StateLoader stateLoader = mock(StateLoader.class);
        when(stateLoader.loadBool("answerShown", false)).thenReturn(true);

// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateLoader.java
// public interface StateLoader {
//     int loadInt(String key, int defaultIfNotFound);
//     boolean loadBool(String key, boolean defaultIfNotFound);
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateSaver.java
// public interface StateSaver {
//     void saveInt(String key, int value);
//     void saveBool(String key, boolean value);
// }


// Path: chapter5-geoquiz-challenges/app/src/test/java/com/olerass/pfexample/android/geoquiz/domain/cheat/StandardCheatModelTest.java
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.state.StateLoader;
import com.olerass.pfexample.android.geoquiz.domain.state.StateSaver;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

        StandardCheatModel model = new StandardCheatModel("True");
        model.setAnswerShown(false);
        StateSaver stateSaver = mock(StateSaver.class);

        model.saveState(stateSaver);

        verify(stateSaver).saveBool("answerShown", false);
    }

    @Test
    public void loadState_loadsAnswerShown_whenCalled() {
        StandardCheatModel model = new StandardCheatModel("True");
        StateLoader stateLoader = mock(StateLoader.class);
        when(stateLoader.loadBool("answerShown", false)).thenReturn(true);

        model.loadState(stateLoader);
        boolean answerShown = model.isAnswerShown();

        assertEquals(true, answerShown);
    }

    @Test
    public void loadState_notifiesListenerThatAnswerShownChanged_whenLoadedValueIsDifferentFromCurrent() {
        StandardCheatModel model = new StandardCheatModel("True");
        model.setAnswerShown(false);
        EventListener listener = mock(EventListener.class);
        model.whenAnswerShownChanged(listener);
        StateLoader stateLoader = mock(StateLoader.class);
        when(stateLoader.loadBool("answerShown", false)).thenReturn(true);

        model.loadState(stateLoader);