Esempio n. 1
0
  /** Tests the RacingAthlete.toString() method. */
  @Test
  public void testToString() {
    // Preparations

    defaultAthlete.setName(_defaultName);
    defaultAthlete.setAge(_defaultAge);

    defaultAthlete.setContestantID(_defaultID);

    String athleteString = defaultAthlete.toString();

    // Class

    assertTrue(
        "Does not contain class name",
        athleteString.contains(defaultAthlete.getClass().getSimpleName()));

    // Person Interface

    assertTrue("Does not contain name", athleteString.contains(_defaultName));

    assertTrue("Does not contain age", athleteString.contains(Integer.toString(_defaultAge)));

    // RaceParticipant Interface

    assertTrue("Does not contain ID", athleteString.contains(Integer.toString(_defaultID)));
  }
Esempio n. 2
0
  /** Person: Test the age setter/getter. */
  @Test
  public void testSetGetAge() {
    defaultAthlete.setAge(_defaultAge);

    assertEquals("Age is not set properly", _defaultAge, defaultAthlete.getAge());
  }
Esempio n. 3
0
 /** Person: Test that age is in sensible bounds. */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testSetAge_Throws_OnTooHigh() {
   defaultAthlete.setAge(301);
 }