/** 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))); }
/** RaceParticipant: Test that the contestantID remains in sensible bounds. */ @Test(expected = IndexOutOfBoundsException.class) public void testSetContestantID_Throws_OnTooLow() { // < 1 defaultAthlete.setContestantID(0); }
/** RaceParticipant: Test that the contestantID remains in sensible bounds. */ @Test(expected = IndexOutOfBoundsException.class) public void testSetContestantID_Throws_OnTooHigh() { // > 100.000 defaultAthlete.setContestantID(100001); }
/** RaceParticipant: Test the contestantID setter/getter. */ @Test public void testSetGetContestantID() { defaultAthlete.setContestantID(_defaultID); assertEquals("ID is not set properly", _defaultID, defaultAthlete.getContestantID()); }