Esempio n. 1
0
  @Test
  public void should_show_statistics_on_first_question_of_resume_game()
      throws IOException, ItemException {

    Set<Integer> answeredItemId = new HashSet<Integer>();
    answeredItemId.add(0);
    Set<Integer> goodAnsweredItemId = new HashSet<Integer>();
    goodAnsweredItemId.add(0);
    Stats stats = new Stats(answeredItemId, goodAnsweredItemId);

    GameState gameState = new GameState(Arrays.asList(1, 2));

    commonExpectsInitGame(gameState, stats);

    expect(repositoryItemsCache.getItem(GameState.class)).andReturn(gameState);
    expect(repositoryItemsCache.getItem(Stats.class)).andReturn(stats);

    testModule.replay();

    quizzActivity.onCreate(null);

    quizzActivity.findViewById(R.id.buttonResumeGame).performClick();

    TableLayout footerTable = (TableLayout) quizzActivity.findViewById(R.id.footerTable);
    TextView score = (TextView) quizzActivity.findViewById(R.id.ScoreTextView);
    assertEquals(View.VISIBLE, footerTable.getVisibility());
    assertEquals("Score: 1 / 3", score.getText().toString());
  }
Esempio n. 2
0
  @Test
  public void should_not_show_resume_game_button() throws IOException, ItemException {

    commonExpectsInitGame(buildEMptyGameState(), buildEmptyStats());

    testModule.replay();

    quizzActivity.onCreate(null);

    Button resumeGameButton = (Button) quizzActivity.findViewById(R.id.buttonResumeGame);
    assertEquals(View.GONE, resumeGameButton.getVisibility());

    testModule.verify();
  }
Esempio n. 3
0
  @Test
  public void should_show_resume_game_button() throws ItemException, IOException {

    Set<Integer> answeredItemId = new HashSet<Integer>();
    answeredItemId.add(0);
    Set<Integer> goodAnsweredItemId = new HashSet<Integer>();
    goodAnsweredItemId.add(0);
    Stats stats = new Stats(answeredItemId, goodAnsweredItemId);

    GameState gameState = new GameState(Arrays.asList(1, 2));

    commonExpectsInitGame(gameState, stats);

    testModule.replay();

    quizzActivity.onCreate(null);

    Button resumeGameButton = (Button) quizzActivity.findViewById(R.id.buttonResumeGame);
    assertEquals(
        "Resume button should be visible.", View.VISIBLE, resumeGameButton.getVisibility());

    testModule.verify();
  }