예제 #1
0
  public void testInit_NoRating() {
    Game game = GameBuilder.aGame().build();
    when(gameRatingDao.getRatingOf(any(Game.class))).thenReturn(null);

    presenter.init(game);

    verify(view, times(1)).showGame(game);
    verify(view, never()).showRating(anyFloat());
    verify(gameRatingDao, times(1)).getRatingOf(game);
    verify(view, never()).showPlataforms(game.getPlatforms());
    verify(view, times(1)).warnNoPlatform();
  }
예제 #2
0
  public void testSetRating_RatingNotNull() {
    float firstRating = 1f;
    float secondRating = 2f;
    Game game = GameBuilder.aGame().build();
    when(gameRatingDao.getRatingOf(any(Game.class))).thenReturn(firstRating);

    presenter.init(game);
    presenter.setRating(secondRating);

    verify(gameRatingDao, never()).insert(game, secondRating);
    verify(gameRatingDao, times(1)).update(game, secondRating);
  }
예제 #3
0
  public void testInit_WithPlatform() {
    Float rating = 2f;
    Game game = GameBuilder.aGame().withPlatform(PlatformBuilder.aPlatform().build()).build();
    when(gameRatingDao.getRatingOf(any(Game.class))).thenReturn(rating);

    presenter.init(game);

    verify(view, times(1)).showGame(game);
    verify(view, times(1)).showRating(rating);
    verify(gameRatingDao, times(1)).getRatingOf(game);
    verify(view, times(1)).showPlataforms(game.getPlatforms());
    verify(view, never()).warnNoPlatform();
  }