Skip to content
Merged
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
52 changes: 52 additions & 0 deletions Ical.Net.Tests/WikiSamples/RecurrenceWikiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
""";

// Non-Wiki Asserts
Assert.That(RemoveIrrelevantProperties(generatedIcs), Is.EqualTo(expectedIcs));

Check warning on line 167 in Ical.Net.Tests/WikiSamples/RecurrenceWikiTests.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'generatedIcs' in 'string RecurrenceWikiTests.RemoveIrrelevantProperties(string generatedIcs, string[]? keep = null)'.

Check warning on line 167 in Ical.Net.Tests/WikiSamples/RecurrenceWikiTests.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'generatedIcs' in 'string RecurrenceWikiTests.RemoveIrrelevantProperties(string generatedIcs, string[]? keep = null)'.

Check warning on line 167 in Ical.Net.Tests/WikiSamples/RecurrenceWikiTests.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'generatedIcs' in 'string RecurrenceWikiTests.RemoveIrrelevantProperties(string generatedIcs, string[]? keep = null)'.

Check warning on line 167 in Ical.Net.Tests/WikiSamples/RecurrenceWikiTests.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'generatedIcs' in 'string RecurrenceWikiTests.RemoveIrrelevantProperties(string generatedIcs, string[]? keep = null)'.

var generatedOccurrences = ToWikiPeriodString(occurrences);
Assert.That(generatedOccurrences, Is.EqualTo(expectedOccurrences));
Expand Down Expand Up @@ -593,6 +593,58 @@
_logger.LogDebug(expectedOccurrences);
}

[Test]
public void GetFirstOccurrenceOfAllCalendarEvents()
{
// Wiki code start

var calendar = new Calendar();
var start = new CalDateTime(2025, 9, 1, 10, 0, 0, CalDateTime.UtcTzId);

// Event that recurs daily
calendar.Events.Add(new CalendarEvent
{
Summary = "Daily event",
Start = start,
End = start.AddHours(1),
RecurrenceRules = [new RecurrencePattern(FrequencyType.Daily, interval: 1)]
});

// Simple event in far future
calendar.Events.Add(new CalendarEvent
{
Summary = "Far future event",
Start = start.AddYears(10),
End = start.AddYears(10).AddHours(1)
});

var occurrences =
calendar.Events
.SelectMany(ev => ev.GetOccurrences().Take(1))
.ToArray();

// Wiki code end

// Occurrences
const string expectedOccurrences =
"""
2 occurrences:
Start: 09/01/2025 10:00:00 +00:00 UTC
Period: PT1H
End: 09/01/2025 11:00:00 +00:00 UTC
Start: 09/01/2035 10:00:00 +00:00 UTC
Period: PT1H
End: 09/01/2035 11:00:00 +00:00 UTC
""";

// Non-Wiki Asserts

var generatedOccurrences = ToWikiPeriodString(occurrences);
Assert.That(generatedOccurrences, Is.EqualTo(expectedOccurrences));

_logger.LogDebug(expectedOccurrences);
}

[Test]
public void MoreRecurrenceRuleExamples()
{
Expand Down
Loading