ReaderViewPresenter extends BasePresenter<ReaderView> implements TTSPlayerFragment.OnTTSStopSpeakListener { void inverseNightMode() { boolean nightMode = !preferenceHelper.getTextAppearance().isNightMode(); preferenceHelper.setNightMode(nightMode); getView().setTextAppearance(preferenceHelper.getTextAppearance()); } @Inject  ReaderViewPresenter(Librarian librarian, PreferenceHelper prefHelper, AnalyticsHelper helper); @Override void onStopSpeak(); @Override void onViewCreated();  }
@Test public void inverseNightMode() throws Exception { TextAppearance textAppearance = mock(TextAppearance.class); when(textAppearance.isNightMode()).thenReturn(false); when(preferenceHelper.getTextAppearance()).thenReturn(textAppearance); doAnswer(invocation -> { when(textAppearance.isNightMode()).thenReturn(invocation.getArgument(0)); return null; }).when(preferenceHelper).setNightMode(anyBoolean()); presenter.inverseNightMode(); ArgumentCaptor<TextAppearance> captor = ArgumentCaptor.forClass(TextAppearance.class); verify(view).setTextAppearance(captor.capture()); assertTrue(captor.getValue().isNightMode()); }