コード例 #1
0
  /**
   * 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;
  }
コード例 #2
0
  /**
   * Test method for {@link
   * de.unikassel.android.sdcframework.data.WeekdaySchedule#equals(java.lang.Object)} .
   */
  public final void testEquals() {
    WeekdaySchedule daySchedule = createWeekdayScheduleForTest();
    WeekdaySchedule otherDaySchedule = new WeekdaySchedule(daySchedule.getWeekday());
    assertFalse("Expected unequal day schedules", otherDaySchedule.equals(daySchedule));

    for (WeekdayScheduleEntry entry : daySchedule.getEntries()) {
      otherDaySchedule.addEntry(new WeekdayScheduleEntry(entry));
    }

    assertTrue("Expected equal day schedules", otherDaySchedule.equals(daySchedule));
  }
コード例 #3
0
  /**
   * Test method for {@link
   * de.unikassel.android.sdcframework.data.WeekdaySchedule#addEntry(de.unikassel.android.sdcframework.data.WeekdayScheduleEntry)}
   * and {@link de.unikassel.android.sdcframework.data.WeekdaySchedule#getEntries()} and {@link
   * de.unikassel.android.sdcframework.data.WeekdaySchedule#removeEntry(de.unikassel.android.sdcframework.data.WeekdayScheduleEntry)}
   * .
   */
  public final void testEntryList() {
    WeekdaySchedule daySchedule = new WeekdaySchedule(Weekday.Saturday);
    assertNotNull("Expected entry list available", daySchedule.getEntries());
    assertEquals("Expected entry list empty", 0, daySchedule.getEntries().size());

    List<WeekdayScheduleEntry> entries = createWeekdayScheduleEntriesForTest();
    int cnt = 0;
    for (WeekdayScheduleEntry entry : entries) {
      daySchedule.addEntry(entry);
      cnt++;
      assertTrue("Expected entry added", daySchedule.getEntries().contains(entry));
      assertEquals("Unexpected entry count", cnt, daySchedule.getEntries().size());
    }

    assertEquals("Expected same entry count", entries.size(), daySchedule.getEntries().size());
    assertTrue("Expected all entries added", daySchedule.getEntries().containsAll(entries));

    WeekdayScheduleEntry entryToRemove = entries.get(entries.size() >> 1);
    daySchedule.removeEntry(entryToRemove);
    assertFalse("Expected entry removed", daySchedule.getEntries().contains(entryToRemove));
    assertEquals("Unexpected entry count", entries.size() - 1, daySchedule.getEntries().size());
  }