Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions Ical.Net.Benchmarks/OccurencePerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Ical.Net.Benchmarks;
Expand Down Expand Up @@ -66,10 +65,7 @@ private static Calendar GenerateCalendarWithRecurrences()
{
Start = new CalDateTime(2025, 3, 1),
End = null,
RecurrenceRules = new List<RecurrencePattern>
{
new RecurrencePattern(FrequencyType.Daily, 1) { Count = 1000 }
}
RecurrenceRule = new(FrequencyType.Daily, 1) { Count = 1000 }
};
calendar.Events.Add(dailyEvent);
return calendar;
Expand All @@ -96,7 +92,7 @@ private static Calendar GetFourCalendarEventsWithUntilRule()
{
Start = startTime.AddMinutes(5).ToTimeZone(tzid),
End = startTime.AddMinutes(10).ToTimeZone(tzid),
RecurrenceRules = new List<RecurrencePattern> { rrule },
RecurrenceRule = rrule,
};
startTime = startTime.Add(Duration.FromTimeSpanExact(interval));
return e;
Expand Down Expand Up @@ -160,7 +156,7 @@ private static Calendar GetFourCalendarEventsWithCountRule()
{
Start = new CalDateTime(startTime.AddMinutes(5), tzid),
End = new CalDateTime(startTime.AddMinutes(10), tzid),
RecurrenceRules = new List<RecurrencePattern> { rrule },
RecurrenceRule = rrule,
};
startTime = startTime.Add(interval);
return e;
Expand Down
8 changes: 2 additions & 6 deletions Ical.Net.Benchmarks/SerializationPerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Ical.Net.DataTypes;
using Ical.Net.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Ical.Net.Benchmarks;
Expand Down Expand Up @@ -83,12 +82,9 @@ private static Calendar CreateSimpleCalendar()
{
Start = new CalDateTime(DateTime.Now, timeZoneId),
End = new CalDateTime(DateTime.Now + TimeSpan.FromHours(1), timeZoneId),
RecurrenceRules = new List<RecurrencePattern>
RecurrenceRule = new(FrequencyType.Daily, 1)
{
new RecurrencePattern(FrequencyType.Daily, 1)
{
Count = 100,
}
Count = 100,
}
};

Expand Down
2 changes: 1 addition & 1 deletion Ical.Net.Tests/CalDateTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static CalendarEvent GetEventWithRecurrenceRules(string tzId)
{
Start = new CalDateTime(_now, tzId),
End = new CalDateTime(_later, tzId),
RecurrenceRules = new List<RecurrencePattern> { dailyForFiveDays },
RecurrenceRule = dailyForFiveDays,
Resources = new List<string>(new[] { "Foo", "Bar", "Baz" }),
};
return calendarEvent;
Expand Down
32 changes: 15 additions & 17 deletions Ical.Net.Tests/DocumentationExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Daily_Test()
Until = new CalDateTime("20160731T235959")
};

vEvent.RecurrenceRules = new List<RecurrencePattern> { recurrenceRule };
vEvent.RecurrenceRule = recurrenceRule;
var calendar = new Calendar();
calendar.Events.Add(vEvent);

Expand All @@ -53,14 +53,13 @@ public void EveryOtherTuesdayUntilTheEndOfTheYear_Test()
{
DtStart = new CalDateTime(DateTime.Parse("2016-07-05T07:00", CultureInfo.InvariantCulture)),
DtEnd = new CalDateTime(DateTime.Parse("2016-07-05T08:00",CultureInfo.InvariantCulture)),
};

// Recurring every other Tuesday until Dec 31
var rrule = new RecurrencePattern(FrequencyType.Weekly, 2)
{
Until = new CalDateTime("20161231T115959")
// Recurring every other Tuesday until Dec 31
RecurrenceRule = new(FrequencyType.Weekly, 2)
{
Until = new CalDateTime("20161231T115959")
}
};
vEvent.RecurrenceRules = new List<RecurrencePattern> { rrule };

// Count every other Tuesday between July 1 and Dec 31.
// The first Tuesday is July 5. There should be 13 in total
Expand All @@ -80,17 +79,16 @@ public void FourthThursdayOfNovember_Tests()
{
DtStart = new CalDateTime(DateTime.Parse("2000-11-23T07:00", CultureInfo.InvariantCulture)),
DtEnd = new CalDateTime(DateTime.Parse("2000-11-23T19:00", CultureInfo.InvariantCulture)),
};

// Recurring every other Tuesday until Dec 31
var rrule = new RecurrencePattern(FrequencyType.Yearly, 1)
{
Frequency = FrequencyType.Yearly,
Interval = 1,
ByMonth = new List<int> { 11 },
ByDay = new List<WeekDay> { new WeekDay { DayOfWeek = DayOfWeek.Thursday, Offset = 4 } },
// Recurring every other Tuesday until Dec 31
RecurrenceRule = new(FrequencyType.Yearly, 1)
{
Frequency = FrequencyType.Yearly,
Interval = 1,
ByMonth = [11],
ByDay = [new WeekDay { DayOfWeek = DayOfWeek.Thursday, Offset = 4 }],
}
};
vEvent.RecurrenceRules = new List<RecurrencePattern> { rrule };

var searchStart = new CalDateTime(2000, 01, 01);
var searchEnd = new CalDateTime(2017, 01, 01);
Expand All @@ -111,7 +109,7 @@ public void DailyExceptSunday_Test()
{
DtStart = new CalDateTime(DateTime.Parse("2016-01-01T07:00", CultureInfo.InvariantCulture)),
DtEnd = new CalDateTime(DateTime.Parse("2016-12-31T08:00", CultureInfo.InvariantCulture)),
RecurrenceRules = new List<RecurrencePattern> { new RecurrencePattern(FrequencyType.Daily, 1) },
RecurrenceRule = new(FrequencyType.Daily, 1),
};

//Define the exceptions: Sunday
Expand Down
12 changes: 6 additions & 6 deletions Ical.Net.Tests/MatchTimeZoneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void MatchTimeZone_LocalTimeUsaWithTimeZone()

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = new CalDateTime(2023, 11, 05, 13, 00, 00, CalDateTime.UtcTzId);
var occurrences = evt.GetOccurrences(new CalDateTime(2023, 11, 01)).TakeWhileBefore(new CalDateTime(2023, 11, 06));
Expand Down Expand Up @@ -81,7 +81,7 @@ public void MatchTimeZone_LocalTimeAustraliaWithTimeZone(string inputUntil, int

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = DateTime.ParseExact(inputUntil, "yyyyMMddTHHmmssZ",
System.Globalization.CultureInfo.InvariantCulture,
Expand Down Expand Up @@ -130,7 +130,7 @@ public void MatchTimeZone_UTCTime()

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = new CalDateTime(2023, 11, 05, 09, 00, 00, CalDateTime.UtcTzId);
var occurrences = evt.GetOccurrences(new CalDateTime(2023, 11, 01)).TakeWhileBefore(new CalDateTime(2023, 11, 06));
Expand Down Expand Up @@ -163,7 +163,7 @@ public void MatchTimeZone_FloatingTime()

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = new CalDateTime(2023, 11, 05, 09, 00, 00, null);
var occurrences = evt.GetOccurrences(new CalDateTime(2023, 11, 01)).TakeWhileBefore(new CalDateTime(2023, 11, 06));
Expand Down Expand Up @@ -197,7 +197,7 @@ public void MatchTimeZone_LocalTimeNoTimeZone()

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = new CalDateTime(2023, 11, 05, 09, 00, 00, null);
var occurrences = evt.GetOccurrences(new CalDateTime(2023, 11, 01)).TakeWhileBefore(new CalDateTime(2023, 11, 06));
Expand Down Expand Up @@ -230,7 +230,7 @@ public void MatchTimeZone_DateOnly()

var calendar = Calendar.Load(ical);
var evt = calendar.Events.First();
var until = evt.RecurrenceRules.First().Until;
var until = evt.RecurrenceRule.Until;

var expectedUntil = new CalDateTime(2023, 11, 05);
var occurrences = evt.GetOccurrences(new CalDateTime(2023, 11, 01)).TakeWhileBefore(new CalDateTime(2023, 11, 06));
Expand Down
Loading
Loading