Exemplo n.º 1
0
        public void TestTodoActive(string calendar, ArrayList items, params int[] numPeriods)
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar)[0];

            ProgramTest.TestCal(iCal);
            ITodo todo = iCal.Todos[0];

            for (int i = 0; i < items.Count; i += 2)
            {
                iCalDateTime dt = (iCalDateTime)items[i];
                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)
            {
                IEvaluator evaluator = todo.GetService(typeof(IEvaluator)) as IEvaluator;
                Assert.IsNotNull(evaluator);
                Assert.AreEqual(
                    numPeriods[0],
                    evaluator.Periods.Count,
                    "Todo should have " + numPeriods[0] + " occurrences after evaluation; it had " + evaluator.Periods.Count);
            }
        }