Search in sources :

Example 1 with CharacterListPresenter

use of saulmm.avengers.mvp.presenters.CharacterListPresenter in project Avengers by saulmm.

the class ListPresenterTest method testThatPresenterShowsErrorWhenLoadingCharacters.

@Test
public void testThatPresenterShowsErrorWhenLoadingCharacters() throws Exception {
    CharacterListPresenter listPresenter = givenAListPresenter();
    when(mockGetCharacterUsecase.execute()).thenReturn(Observable.error(new Exception()));
    listPresenter.askForCharacters();
    verify(mockCharacterListView, times(1)).showUknownErrorMessage();
}
Also used : CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Test(org.junit.Test)

Example 2 with CharacterListPresenter

use of saulmm.avengers.mvp.presenters.CharacterListPresenter in project Avengers by saulmm.

the class ListPresenterTest method testThatPresenterRequestMoreCharacters.

@Test
public void testThatPresenterRequestMoreCharacters() throws Exception {
    CharacterListPresenter listPresenter = givenAListPresenter();
    when(mockGetCharacterUsecase.execute()).thenReturn(getFakeObservableCharacterList());
    listPresenter.askForNewCharacters();
    verify(mockGetCharacterUsecase, only()).execute();
}
Also used : CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Test(org.junit.Test)

Example 3 with CharacterListPresenter

use of saulmm.avengers.mvp.presenters.CharacterListPresenter in project Avengers by saulmm.

the class ListPresenterTest method testThatPresenterShowsALightErrorLoadingMoreCharacters.

@Test
public void testThatPresenterShowsALightErrorLoadingMoreCharacters() throws Exception {
    CharacterListPresenter listPresenter = givenAListPresenter();
    when(mockGetCharacterUsecase.execute()).thenReturn(Observable.error(new Exception()));
    listPresenter.askForNewCharacters();
    verify(mockCharacterListView, times(1)).showLightError();
}
Also used : CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Test(org.junit.Test)

Example 4 with CharacterListPresenter

use of saulmm.avengers.mvp.presenters.CharacterListPresenter in project Avengers by saulmm.

the class ListPresenterTest method givenAListPresenter.

private CharacterListPresenter givenAListPresenter() {
    CharacterListPresenter listPresenter = new CharacterListPresenter(mockGetCharacterUsecase);
    listPresenter.attachView(mockCharacterListView);
    return listPresenter;
}
Also used : CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter)

Example 5 with CharacterListPresenter

use of saulmm.avengers.mvp.presenters.CharacterListPresenter in project Avengers by saulmm.

the class ListPresenterTest method testThatCharactersArePassedToTheView.

@Test
public void testThatCharactersArePassedToTheView() throws Exception {
    CharacterListPresenter listPresenter = givenAListPresenter();
    ArrayList<MarvelCharacter> fakeCharacterList = givenAFakeCharacterList();
    listPresenter.onCharactersReceived(fakeCharacterList);
    verify(mockCharacterListView, times(1)).bindCharacterList(fakeCharacterList);
}
Also used : MarvelCharacter(saulmm.avengers.entities.MarvelCharacter) CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Test(org.junit.Test)

Aggregations

CharacterListPresenter (saulmm.avengers.mvp.presenters.CharacterListPresenter)6 Test (org.junit.Test)5 MarvelCharacter (saulmm.avengers.entities.MarvelCharacter)1