/** * Test method for {@link * de.unikassel.android.sdcframework.data.WeekdaySchedule#WeekdaySchedule(de.unikassel.android.sdcframework.data.Weekday)} * and {@link de.unikassel.android.sdcframework.data.WeekdaySchedule#getWeekday()} . */ public final void testWeekdayScheduleWeekday() { for (Weekday weekday : Weekday.values()) { WeekdaySchedule daySchedule = new WeekdaySchedule(weekday); assertEquals("Unexpected weekday", weekday, daySchedule.getWeekday()); assertNotNull("Expected entry list intitialized", daySchedule.getEntries()); assertTrue("Expected entry list empty", daySchedule.getEntries().isEmpty()); } }
/** * Test method for {@link * de.unikassel.android.sdcframework.data.WeekdaySchedule#WeekdaySchedule(de.unikassel.android.sdcframework.data.Weekday, * java.util.List)} . */ public final void testWeekdayScheduleWeekdayListOfWeekdayScheduleEntry() { List<WeekdayScheduleEntry> randomEntryList = createWeekdayScheduleEntriesForTest(); Weekday randomWeekday = Weekday.valueOfOrdinal((int) (Math.random() * 7)); WeekdaySchedule daySchedule = new WeekdaySchedule(randomWeekday, randomEntryList); assertEquals("Unexpected weekday", randomWeekday, daySchedule.getWeekday()); assertNotNull("Expected entry list intitialized", daySchedule.getEntries()); assertEquals( "Expected same entry count", randomEntryList.size(), daySchedule.getEntries().size()); assertTrue("Expected all entries added", daySchedule.getEntries().containsAll(randomEntryList)); }
/** * Does create a weekday schedule for test purpose. * * @return a weekday schedule for test purpose. */ public static WeekdaySchedule createWeekdayScheduleForTest() { WeekdaySchedule schedule = new WeekdaySchedule(Weekday.valueOfOrdinal((int) (Math.random() * 7))); List<WeekdayScheduleEntry> entries = createWeekdayScheduleEntriesForTest(); for (WeekdayScheduleEntry entry : entries) { schedule.addEntry(entry); } return schedule; }