Пример #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)));
  }
Пример #2
0
 /** Person: Test that name throws on empty string. */
 @Test(expected = IllegalArgumentException.class)
 public void testSetName_Throws_OnEmpty() {
   defaultAthlete.setName("");
 }
Пример #3
0
  /** Person: Test the name setter/getter. */
  @Test
  public void testSetGetName() {
    defaultAthlete.setName(_defaultName);

    assertEquals("Name is not set properly", _defaultName, defaultAthlete.getName());
  }