コード例 #1
0
ファイル: iCalTimeZone.cs プロジェクト: MaitreDede/dday-ical
        static private void PopulateiCalTimeZoneInfo(iCalTimeZoneInfo tzi, System.TimeZoneInfo.TransitionTime transition, int year)
        {
            Calendar c = CultureInfo.CurrentCulture.Calendar;

            RecurrencePattern recurrence = new RecurrencePattern();
            recurrence.Frequency = FrequencyType.Yearly;
            recurrence.ByMonth.Add(transition.Month);
            recurrence.ByHour.Add(transition.TimeOfDay.Hour);
            recurrence.ByMinute.Add(transition.TimeOfDay.Minute);

            if (transition.IsFixedDateRule)
            {
                recurrence.ByMonthDay.Add(transition.Day);
            }
            else
            {
                recurrence.ByDay.Add(new DaySpecifier(transition.DayOfWeek));
                int daysInMonth = c.GetDaysInMonth(year, transition.Month);
                int offset = (transition.Week * 7) - 7;
                if (offset + 7 > daysInMonth)
                    offset = daysInMonth - 7;

                // Add the possible days of the month this could occur.
                for (int i = 1; i <= 7; i++)
                    recurrence.ByMonthDay.Add(i + offset + (int)transition.DayOfWeek);
            }

            tzi.AddRecurrencePattern(recurrence);
        }
コード例 #2
0
ファイル: Serialize.cs プロジェクト: MaitreDede/dday-ical
        public void SERIALIZE19()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new iCalDateTime(2007, 4, 29);
            evt.End = evt.Start.AddDays(1);
            evt.IsAllDay = true;

            RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.AddRecurrencePattern(rec);

            ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt);

            FileStream fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Create, FileAccess.Write);
            compSerializer.Serialize(fs, Encoding.UTF8);
            fs.Close();

            iCalendar iCal1 = new iCalendar();
            
            fs = new FileStream(@"Calendars\Serialization\SERIALIZE19.ics", FileMode.Open, FileAccess.Read);
            Event evt1 = ComponentBase.LoadFromStream<Event>(fs, Encoding.UTF8);            
            fs.Close();

            CompareComponents(evt, evt1);
        }
コード例 #3
0
ファイル: Serialize.cs プロジェクト: MaitreDede/dday-ical
        public void SERIALIZE18()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new iCalDateTime(2007, 3, 19);
            evt.Start.IsUniversalTime = true;
            evt.Duration = new TimeSpan(24, 0, 0);
            evt.Created = evt.Start.Copy();
            evt.DTStamp = evt.Start.Copy();
            evt.UID = "123456789";
            evt.IsAllDay = true;

            RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.AddRecurrencePattern(rec);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string icalString = serializer.SerializeToString();

            Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty");

            ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt);
            string evtString = compSerializer.SerializeToString();

            Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND;VALUE=DATE:20070320\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nDURATION:P1D\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSEQUENCE:0\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly");
        }
コード例 #4
0
ファイル: TimeZoneInfo.cs プロジェクト: xxjeng/nuxleus
 public override void AddExceptionPattern(RecurrencePattern recur)
 {
 }
コード例 #5
0
ファイル: Recurrence.cs プロジェクト: MaitreDede/dday-ical
        public void TEST2()
        {
            iCalendar iCal = new iCalendar();
            Event evt = iCal.Create<Event>();
            evt.Summary = "Event summary";
            evt.Start = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);

            RecurrencePattern recur = new RecurrencePattern();
            recur.Frequency = FrequencyType.Daily;
            recur.Count = 3;
            recur.ByDay.Add(new DaySpecifier(DayOfWeek.Monday));
            recur.ByDay.Add(new DaySpecifier(DayOfWeek.Wednesday));
            recur.ByDay.Add(new DaySpecifier(DayOfWeek.Friday));
            evt.AddRecurrencePattern(recur);

            DDay.iCal.Serialization.iCalendar.DataTypes.RecurrencePatternSerializer serializer =
                new DDay.iCal.Serialization.iCalendar.DataTypes.RecurrencePatternSerializer(recur);
            Assert.IsTrue(string.Compare(serializer.SerializeToString(), "FREQ=DAILY;COUNT=3;BYDAY=MO,WE,FR") == 0,
                "Serialized recurrence string is incorrect");
        }
コード例 #6
0
ファイル: Recurrence.cs プロジェクト: MaitreDede/dday-ical
        public void TEST1()
        {
            iCalendar iCal = new iCalendar();
            Event evt = iCal.Create<Event>();
            evt.Summary = "Event summary";
            evt.Start = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);

            RecurrencePattern recur = new RecurrencePattern();
            evt.AddRecurrencePattern(recur);

            try
            {
                List<Period> periods = evt.Evaluate(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2));
                Assert.Fail("An exception should be thrown when evaluating a recurrence with no specified FREQUENCY");
            }
            catch { }
        }
コード例 #7
0
 public RecurrencePatternSerializer(DDay.iCal.DataTypes.RecurrencePattern recur)
     : base(recur)
 {
     this.m_Recur = recur;
 }
コード例 #8
0
        public List<iCalDateTime> Evaluate(iCalDateTime StartDate, iCalDateTime FromDate, iCalDateTime ToDate)
        {
            List<iCalDateTime> DateTimes = new List<iCalDateTime>();
            DateTimes.AddRange(StaticOccurrences);

            // Create a temporary recurrence for populating 
            // missing information using the 'StartDate'.
            RecurrencePattern r = new RecurrencePattern();
            r.CopyFrom(this);

            // Enforce evaluation engine rules
            r.EnforceEvaluationRestrictions();

            // Fill in missing, necessary ByXXX values
            r.EnsureByXXXValues(StartDate);
                        
            // Get the occurrences
            foreach (iCalDateTime occurrence in r.GetOccurrences(StartDate, FromDate.Copy(), ToDate.Copy(), r.Count))
            {
                // NOTE:
                // Used to be DateTimes.AddRange(r.GetOccurrences(FromDate.Copy(), ToDate, r.Count))
                // By doing it this way, fixes bug #19.
                if (!DateTimes.Contains(occurrence))
                    DateTimes.Add(occurrence);
            }

            // Limit the count of returned recurrences
            if (Count != int.MinValue &&
                DateTimes.Count > Count)
                DateTimes.RemoveRange(Count, DateTimes.Count - Count);

            // Process the UNTIL, and make sure the DateTimes
            // occur between FromDate and ToDate
            for (int i = DateTimes.Count - 1; i >= 0; i--)
            {
                iCalDateTime dt = (iCalDateTime)DateTimes[i];
                if (dt > ToDate ||
                    dt < FromDate)
                    DateTimes.RemoveAt(i);
            }

            // Assign missing values
            foreach (iCalDateTime dt in DateTimes)
                dt.MergeWith(StartDate);

            // Ensure that DateTimes have an assigned time if they occur less than daily
            foreach (iCalDateTime dt in DateTimes)
            {
                if (Frequency < FrequencyType.Daily)
                    dt.HasTime = true;
            }
            
            return DateTimes;
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: xxjeng/nuxleus
        /// <summary>
        /// Creates a calendar with 2 events, and returns it.
        /// </summary>
        static iCalendar CreateCalendar()
        {
            // First load a file containing time zone information for North & South America
            iCalendar timeZones = iCalendar.LoadFromFile("America.ics");

            // Add the time zones we are going to use to our calendar
            // If we're not sure what we'll use, we could simply copy the
            // entire time zone information instead:
            //
            // iCalendar iCal = timeZones.Copy();
            //
            // This will take significantly more disk space, and can slow
            // down performance, so I recommend you determine which time
            // zones will be used and only copy the necessary zones.
            iCalendar iCal = new iCalendar();
            iCal.AddChild(timeZones.GetTimeZone("America/New_York"));
            iCal.AddChild(timeZones.GetTimeZone("America/Denver"));            

            // Create an event and attach it to the iCalendar.
            Event evt = iCal.Create<Event>();

            // Set the one-line summary of the event
            evt.Summary = "The first Monday and second-to-last Monday of each month";

            // Set the longer description of the event
            evt.Description = "A more in-depth description of this event.";
            
            // Set the event to start at 11:00 A.M. New York time on January 2, 2007.
            evt.Start = new iCalDateTime(2007, 1, 2, 11, 0, 0, "America/New_York", iCal);

            // Set the duration of the event to 1 hour.
            // NOTE: this will automatically set the End time of the event
            evt.Duration = TimeSpan.FromHours(1);            

            // The event has been confirmed
            evt.Status = EventStatus.Confirmed;

            // Set the geographic location (latitude,longitude) of the event
            evt.Geo = new Geo(114.2938, 32.982);
            
            evt.Location = "Home office";
            evt.Priority = 7;

            // Add an organizer to the event.
            // This is the person who created the event (or who is in charge of it)
            evt.Organizer = "*****@*****.**";
            // Indicate that this organizer is a member of another group
            evt.Organizer.AddParameter("MEMBER", "MAILTO:[email protected]");

            // Add a person who will attend the event
            evt.AddAttendee("*****@*****.**");

            // Add categories to the event
            evt.AddCategory("Work");
            evt.AddCategory("Personal");

            // Add some comments to the event
            evt.AddComment("Comment #1");
            evt.AddComment("Comment #2");

            // Add resources that will be used for the event
            evt.AddResource("Conference Room #2");
            evt.AddResource("Projector #4");

            // Add contact information to this event, with an optional link to further information
            evt.AddContact("Doug Day (XXX) XXX-XXXX", new Uri("http://www.someuri.com/pdi/dougd.vcf"));

            // Set the identifier for the event.  NOTE: this will happen automatically
            // if you don't do it manually.  We set it manually here so we can easily
            // refer to this event later.
            evt.UID = "1234567890";

            // Now, let's add a recurrence pattern to this event.
            // It needs to happen on the first Monday and
            // second to last Monday of each month.
            RecurrencePattern rp = new RecurrencePattern();
            rp.Frequency = FrequencyType.Monthly;
            rp.ByDay.Add(new DaySpecifier(DayOfWeek.Monday, FrequencyOccurrence.First));
            rp.ByDay.Add(new DaySpecifier(DayOfWeek.Monday, FrequencyOccurrence.SecondToLast));            
            evt.AddRecurrencePattern(rp);

            // Let's also add an alarm on this event so we can be reminded of it later.
            Alarm alarm = new Alarm();

            // Display the alarm somewhere on the screen.
            alarm.Action = AlarmAction.Display; 

            // This is the text that will be displayed for the alarm.
            alarm.Summary = "Alarm for the first Monday and second-to-last Monday of each month";

            // The alarm is set to occur 30 minutes before the event
            alarm.Trigger = new Trigger(TimeSpan.FromMinutes(-30));

            // Set the alarm to repeat twice (for a total of 3 alarms)
            // before the event.  Each repetition will occur 10 minutes
            // after the initial alarm.  In english - that means
            // the alarm will go off 30 minutes before the event,
            // then again 20 minutes before the event, and again
            // 10 minutes before the event.
            alarm.Repeat = 2;
            alarm.Duration = TimeSpan.FromMinutes(10);
            
            // Add the alarm to the event
            evt.AddAlarm(alarm);
                        
            // Create another (much more simple) event
            evt = iCal.Create<Event>();
            evt.Summary = "Every month on the 21st";
            evt.Description = "A more in-depth description of this event.";
            evt.Start = new iCalDateTime(2007, 1, 21, 16, 0, 0, "America/New_York", iCal);
            evt.Duration = TimeSpan.FromHours(1.5);

            rp = new RecurrencePattern();
            rp.Frequency = FrequencyType.Monthly;
            evt.AddRecurrencePattern(rp);

            return iCal;
        }
コード例 #10
0
 public RecurrencePatternSerializer(RecurrencePattern recur)
     : base(recur)
 {
     this.m_Recur = recur;
 }
コード例 #11
0
ファイル: RecurrenceTest.cs プロジェクト: xxjeng/nuxleus
        public void RECURRENCEPATTERN2()
        {
            // NOTE: recurrence patterns are not meant to be used directly like this.
            // However, this does make a good test to ensure they behave as they should.
            RecurrencePattern pattern = new RecurrencePattern("FREQ=MINUTELY;INTERVAL=1");

            DateTime fromDate = DateTime.Parse("4/1/2008 10:08:10 AM");
            DateTime toDate = DateTime.Parse("4/1/2008 10:43:23 AM");
            DateTime startDate = DateTime.Parse("3/31/2008 12:00:10 AM");

            List<iCalDateTime> occurrences = pattern.Evaluate(startDate, fromDate, toDate);
            Assert.AreNotEqual(0, occurrences.Count);
        }
コード例 #12
0
ファイル: RecurrenceTest.cs プロジェクト: xxjeng/nuxleus
        public void RECURRENCEPATTERN1()
        {
            // NOTE: recurrence patterns are not meant to be used directly like this.
            // However, this does make a good test to ensure they behave as they should.
            RecurrencePattern pattern = new
            RecurrencePattern("FREQ=SECONDLY;INTERVAL=10");
            pattern.RestrictionType = RecurrenceRestrictionType.NoRestriction;

            DateTime fromDate = DateTime.Parse("3/30/08 11:59:40 PM");
            DateTime toDate = DateTime.Parse("3/31/08 12:00:10 AM");
            DateTime startDate = DateTime.Parse("3/30/08 11:59:40 PM");

            List<iCalDateTime> occurrences = pattern.Evaluate(startDate, fromDate, toDate);
            Assert.AreEqual(4, occurrences.Count);
            Assert.AreEqual(DateTime.Parse("03/30/08 11:59:40 PM"), occurrences[0].Value);
            Assert.AreEqual(DateTime.Parse("03/30/08 11:59:50 PM"), occurrences[1].Value);
            Assert.AreEqual(DateTime.Parse("03/31/08 12:00:00 AM"), occurrences[2].Value);
            Assert.AreEqual(DateTime.Parse("03/31/08 12:00:10 AM"), occurrences[3].Value);
        }
コード例 #13
0
ファイル: Todo.cs プロジェクト: xxjeng/nuxleus
 private void DetermineStartingRecurrence(RecurrencePattern recur, ref iCalDateTime dt)
 {
     if (recur.Count != int.MinValue)
         dt = DTStart.Copy();
     else recur.IncrementDate(ref dt, -recur.Interval);
 }
コード例 #14
0
 public RecurrencePatternSerializer(DDay.iCal.DataTypes.RecurrencePattern recur)
     : base(recur)
 {
     this.m_Recur = recur;
 }
コード例 #15
0
ファイル: DaySpecifier.cs プロジェクト: xxjeng/nuxleus
        public bool CheckValidDate(RecurrencePattern r, iCalDateTime Date)
        {
            bool valid = false;

            if (this.DayOfWeek == Date.Value.DayOfWeek)
                valid = true;

            if (valid && this.Num != int.MinValue)
            {
                int mult = (this.Num < 0) ? -1 : 1;
                int offset = (this.Num < 0) ? 1 : 0;
                int abs = Math.Abs(this.Num);

                switch (r.Frequency)
                {
                    case FrequencyType.Monthly:
                        {
                            DateTime mondt = new DateTime(Date.Value.Year, Date.Value.Month, 1, Date.Value.Hour, Date.Value.Minute, Date.Value.Second, Date.Value.Kind);
                            mondt = DateTime.SpecifyKind(mondt, Date.Value.Kind);
                            if (offset > 0)
                                mondt = mondt.AddMonths(1).AddDays(-1);

                            while (mondt.DayOfWeek != this.DayOfWeek)
                                mondt = mondt.AddDays(mult);

                            for (int i = 1; i < abs; i++)
                                mondt = mondt.AddDays(7 * mult);

                            if (Date.Value.Date != mondt.Date)
                                valid = false;
                        } break;

                    case FrequencyType.Yearly:
                        {
                            // If BYMONTH is specified, then offset our tests
                            // by those months; otherwise, begin with Jan. 1st.
                            // NOTE: fixes USHolidays.ics eval
                            List<int> months = new List<int>();
                            if (r.ByMonth.Count == 0)
                                months.Add(1);
                            else months = r.ByMonth;

                            bool found = false;
                            foreach (int month in months)
                            {
                                DateTime yeardt = new DateTime(Date.Value.Year, month, 1, Date.Value.Hour, Date.Value.Minute, Date.Value.Second, Date.Value.Kind);
                                yeardt = DateTime.SpecifyKind(yeardt, Date.Value.Kind);
                                if (offset > 0)
                                {
                                    // Start at end of year, or end of month if BYMONTH is specified
                                    if (r.ByMonth.Count == 0)
                                        yeardt = yeardt.AddYears(1).AddDays(-1);
                                    else yeardt = yeardt.AddMonths(1).AddDays(-1);
                                }

                                while (yeardt.DayOfWeek != this.DayOfWeek)
                                    yeardt = yeardt.AddDays(mult);

                                for (int i = 1; i < abs; i++)
                                    yeardt = yeardt.AddDays(7 * mult);

                                if (Date.Value == yeardt)
                                    found = true;
                            }

                            if (!found)
                                valid = false;
                        } break;

                    // Ignore other frequencies
                    default: break;
                }
            }
            return valid;
        }
コード例 #16
0
ファイル: Serialize.cs プロジェクト: MaitreDede/dday-ical
        //[Test, Category("Serialization")]
        public void XCAL1()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new iCalDateTime(2007, 4, 29);
            evt.End = evt.Start.AddDays(1);
            evt.IsAllDay = true;

            RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.AddRecurrencePattern(rec);

            xCalSerializer serializer = new xCalSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\XCAL1.xcal");

            SerializeTest("XCAL1.xcal", typeof(xCalSerializer));
        }
コード例 #17
0
            public TimeCalculation(iCalDateTime StartDate, iCalDateTime EndDate, RecurrencePattern Recur)
            {
                this.StartDate = StartDate;
                this.EndDate = EndDate;
                this.Recur = Recur;

                Year = StartDate.Value.Year;
                Month = StartDate.Value.Month;
                Day = StartDate.Value.Day;
                Hour = StartDate.Value.Hour;
                Minute = StartDate.Value.Minute;
                Second = StartDate.Value.Second;

                YearDays = new List<int>(Recur.ByYearDay);
                ByDays = new List<DaySpecifier>(Recur.ByDay);
                Months = new List<int>(Recur.ByMonth);
                Days = new List<int>(Recur.ByMonthDay);
                Hours = new List<int>(Recur.ByHour);
                Minutes = new List<int>(Recur.ByMinute);
                Seconds = new List<int>(Recur.BySecond);
                DateTimes = new List<iCalDateTime>();

                // Only check what months and days are possible for
                // the week's period of time we're evaluating
                // NOTE: fixes RRULE10 evaluation                
                if (Recur.Frequency == FrequencyType.Weekly)
                {                    
                    if (Months.Count == 0)
                    {
                        Months.Add(StartDate.Value.Month);
                        if (StartDate.Value.Month != EndDate.Value.Month)
                            Months.Add(EndDate.Value.Month);
                    }
                    if (Days.Count == 0)
                    {
                        DateTime dt = StartDate.Value;
                        while (dt < EndDate.Value)
                        {
                            Days.Add(dt.Day);
                            dt = dt.AddDays(1);
                        }
                        Days.Add(EndDate.Value.Day);
                    }
                }
                else
                {
                    if (Months.Count == 0) Months.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });                                
                    if (Days.Count == 0) Days.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 });
                }
            }
コード例 #18
0
 public RecurrencePatternSerializer(RecurrencePattern recur)
     : base(recur)
 {
     this.m_Recur = recur;
 }
コード例 #19
0
ファイル: Recurrence.cs プロジェクト: MaitreDede/dday-ical
        public void RRULE43()
        {
            iCalendar iCal = new iCalendar();

            iCalTimeZone tz = iCal.Create<iCalTimeZone>();
            
            tz.TZID = "US-Eastern";
            tz.Last_Modified = new DateTime(1987, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            TimeZoneInfo standard = new TimeZoneInfo(iCalTimeZone.STANDARD, tz);
            standard.Start = new DateTime(1967, 10, 29, 2, 0, 0, DateTimeKind.Utc);            
            standard.AddRecurrencePattern(new RecurrencePattern("FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10"));
            standard.TZOffsetFrom = new UTC_Offset("-0400");
            standard.TZOffsetTo = new UTC_Offset("-0500");
            standard.TimeZoneName = "EST";            

            TimeZoneInfo daylight = new TimeZoneInfo(iCalTimeZone.DAYLIGHT, tz);
            daylight.Start = new DateTime(1987, 4, 5, 2, 0, 0, DateTimeKind.Utc);
            daylight.AddRecurrencePattern(new RecurrencePattern("FREQ=YEARLY;BYDAY=1SU;BYMONTH=4"));
            daylight.TZOffsetFrom = new UTC_Offset("-0500");
            daylight.TZOffsetTo = new UTC_Offset("-0400");
            daylight.TimeZoneName = "EDT";

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2007, 1, 24, 8, 0, 0, tzid, iCal);
            evt.Duration = TimeSpan.FromHours(1);
            evt.End = new iCalDateTime(2007, 1, 24, 9, 0, 0, tzid, iCal);
            RecurrencePattern recur = new RecurrencePattern("FREQ=MONTHLY;INTERVAL=2;BYDAY=4WE");
            evt.AddRecurrencePattern(recur);

            List<Occurrence> occurrences = evt.GetOccurrences(
                new DateTime(2007, 1, 24), 
                new DateTime(2007, 12, 31));

            iCalDateTime[] DateTimes = new iCalDateTime[]
            {                
                new iCalDateTime(2007, 1, 24, 8, 0, 0, tzid, iCal),
                new iCalDateTime(2007, 3, 28, 8, 0, 0, tzid, iCal),
                new iCalDateTime(2007, 5, 23, 8, 0, 0, tzid, iCal),
                new iCalDateTime(2007, 7, 25, 8, 0, 0, tzid, iCal),
                new iCalDateTime(2007, 9, 26, 8, 0, 0, tzid, iCal),
                new iCalDateTime(2007, 11, 28, 8, 0, 0, tzid, iCal)
            };
            
            for (int i = 0; i < DateTimes.Length; i++)
                Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]);

            Assert.AreEqual(
                DateTimes.Length,
                occurrences.Count,                
                "There should be exactly " + DateTimes.Length +
                " occurrences; there were " + occurrences.Count);
        }
コード例 #20
0
        public void TEST4()
        {
            RecurrencePattern rpattern = new RecurrencePattern();
            rpattern.ByDay.Add(new DaySpecifier(DayOfWeek.Saturday));
            rpattern.ByDay.Add(new DaySpecifier(DayOfWeek.Sunday));

            rpattern.Frequency = FrequencyType.Weekly;

            DateTime evtStart = new DateTime(2006, 12, 1);
            DateTime evtEnd = new DateTime(2007, 1, 1);

            // Add the exception dates
            List<iCalDateTime> listOfDateTime = rpattern.Evaluate(evtStart, evtStart, evtEnd);
            Assert.AreEqual(10, listOfDateTime.Count);
            Assert.AreEqual(2, listOfDateTime[0].Day);
            Assert.AreEqual(3, listOfDateTime[1].Day);
            Assert.AreEqual(9, listOfDateTime[2].Day);
            Assert.AreEqual(10, listOfDateTime[3].Day);
            Assert.AreEqual(16, listOfDateTime[4].Day);
            Assert.AreEqual(17, listOfDateTime[5].Day);
            Assert.AreEqual(23, listOfDateTime[6].Day);
            Assert.AreEqual(24, listOfDateTime[7].Day);
            Assert.AreEqual(30, listOfDateTime[8].Day);
            Assert.AreEqual(31, listOfDateTime[9].Day);
        }