public void TestTodoActive(string calendar, ArrayList items, params int[] numPeriods) { iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar); ProgramTest.TestCal(iCal); DDay.iCal.Components.Todo todo = (DDay.iCal.Components.Todo)iCal.Todos[0]; for (int i = 0; i < items.Count; i += 2) { iCalDateTime dt = (iCalDateTime)items[i]; dt.iCalendar = iCal; dt.TZID = tzid; bool tf = (bool)items[i + 1]; if (tf) { Assert.IsTrue(todo.IsActive(dt), "Todo should be active at " + dt); } else { Assert.IsFalse(todo.IsActive(dt), "Todo should not be active at " + dt); } } if (numPeriods != null && numPeriods.Length > 0) { Assert.AreEqual( numPeriods[0], todo.Periods.Count, "Todo should have " + numPeriods[0] + " occurrences after evaluation; it had " + todo.Periods.Count); } }
public void TODO7_1() { iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\TODO7.ics"); DDay.iCal.Components.Todo todo = iCal.Todos[0]; ArrayList items = new ArrayList(); items.Add(new iCalDateTime(2006, 7, 28, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2006, 8, 4, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2006, 9, 1, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2006, 10, 6, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2006, 11, 3, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2006, 12, 1, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2007, 1, 5, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2007, 2, 2, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2007, 3, 2, 9, 0, 0, tzid, iCal)); items.Add(new iCalDateTime(2007, 4, 6, 9, 0, 0, tzid, iCal)); List <Occurrence> occurrences = todo.GetOccurrences( new iCalDateTime(2006, 7, 1, 9, 0, 0), new iCalDateTime(2007, 7, 1, 9, 0, 0)); for (int i = 0; i < items.Count; i++) { Assert.AreEqual(items[i], occurrences[i].Period.StartTime, "TODO should occur at " + items[i] + ", but does not."); } Assert.AreEqual( items.Count, occurrences.Count, "TODO should have " + items.Count + " occurrences; it has " + occurrences.Count); }
static public Todo Create(iCalendar iCal) { Todo t = new Todo(iCal); t.UID = UniqueComponent.NewUID(); return t; }
public void TestTodoCompleted(string calendar, ArrayList items) { iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar); Program.TestCal(iCal); DDay.iCal.Components.Todo todo = (DDay.iCal.Components.Todo)iCal.Todos[0]; todo.Evaluate(new Date_Time(2006, 7, 28, tzid, iCal), new Date_Time(2010, 1, 1, tzid, iCal)); for (int i = 0; i < items.Count; i += 2) { Date_Time dt = (Date_Time)items[i]; dt.iCalendar = iCal; dt.TZID = tzid; bool tf = (bool)items[i + 1]; if (tf) { Assert.IsTrue(todo.IsCompleted(dt), "Todo should be completed at " + dt); } else { Assert.IsFalse(todo.IsCompleted(dt), "Todo should not be completed at " + dt); } } }
static public Todo Create(iCalendar iCal) { Todo t = iCal.Create <Todo>(); return(t); }