You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.4 KiB
63 lines
1.4 KiB
package de.hs_fulda.ciip.projjpn;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
public class BirthdateTest extends TestCase {
|
|
|
|
public void testToString() {
|
|
|
|
// Given
|
|
Birthdate b = new Birthdate(1, 1, 2000);
|
|
|
|
// When
|
|
String expectedDate = "1.1.2000";
|
|
|
|
// Then
|
|
assertEquals(expectedDate, b.toString());
|
|
}
|
|
|
|
public void test_changeBirthdate() {
|
|
// Given
|
|
Birthdate b = new Birthdate(1, 1, 2000);
|
|
|
|
// Change Birthdate
|
|
b.changeBirthdate(2, 3, 2001);
|
|
|
|
// When
|
|
int expectedDay = 2;
|
|
int expectedMonth = 3;
|
|
int expectedYear = 2001;
|
|
|
|
// Then
|
|
assertEquals(2, b.getDay());
|
|
assertEquals(3, b.getMonth());
|
|
assertEquals(2001, b.getYear());
|
|
}
|
|
|
|
public void test_rejectInvalidBirthday() {
|
|
Birthdate birthdate = new Birthdate(0, 0, 0);
|
|
boolean expectedResult = false;
|
|
boolean gotResult = birthdate.isValid(0, 0, 0);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
gotResult = birthdate.isValid(32, 13, 1990);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
gotResult = birthdate.isValid(31, 0, 1980);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
gotResult = birthdate.isValid(31, 13, 1980);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
gotResult = birthdate.isValid(1, 1, 3000);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
gotResult = birthdate.isValid(1, 1, 1900);
|
|
assertEquals(expectedResult, gotResult);
|
|
|
|
expectedResult = true;
|
|
gotResult = birthdate.isValid(1, 5, 2020);
|
|
assertEquals(expectedResult, gotResult);
|
|
}
|
|
|
|
}
|