Skip to content

Commit

Permalink
add - Added recurrence rule version checking
Browse files Browse the repository at this point in the history
---

We've added unit tests related to version checking for recurrence rules.

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 30, 2024
1 parent 6fb7c8e commit 8e7005e
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
40 changes: 40 additions & 0 deletions VisualCard.Tests/Recurrence/RecurrenceV1ParseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void ParseV1Recurrence(string rule, int expectedCount)
{
var rules = RecurrenceParser.ParseRuleV1(rule);
rules.Length.ShouldBe(expectedCount);
rules[0].Version.ShouldBe(new(1, 0));
}

[TestMethod]
Expand All @@ -81,6 +82,7 @@ public void ParseV1RecurrenceMinute()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(12);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule1.interval.ShouldBe(60);
Expand All @@ -94,6 +96,7 @@ public void ParseV1RecurrenceDayOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(2);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule1.interval.ShouldBe(2);
Expand All @@ -114,6 +117,7 @@ public void ParseV1RecurrenceDayOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(3);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule1.interval.ShouldBe(2);
Expand All @@ -134,12 +138,14 @@ public void ParseV1RecurrenceDayComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule1.interval.ShouldBe(1);

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(6);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule2.interval.ShouldBe(10);
Expand All @@ -153,6 +159,7 @@ public void ParseV1RecurrenceDayComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(4);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule1.interval.ShouldBe(7);
Expand All @@ -162,6 +169,7 @@ public void ParseV1RecurrenceDayComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(4);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule2.interval.ShouldBe(15);
Expand All @@ -175,6 +183,7 @@ public void ParseV1RecurrenceWeekOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(4);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.Weekly);
rule1.interval.ShouldBe(1);
Expand All @@ -188,6 +197,7 @@ public void ParseV1RecurrenceWeekOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(2);
rule1.dayTimes[0].isEnd.ShouldBeTrue();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Monday);
Expand All @@ -206,6 +216,7 @@ public void ParseV1RecurrenceWeekComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(2);
rule1.dayTimes[0].isEnd.ShouldBeFalse();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Tuesday);
Expand All @@ -222,6 +233,7 @@ public void ParseV1RecurrenceWeekComplex()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(2);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule2.interval.ShouldBe(30);
Expand All @@ -235,6 +247,7 @@ public void ParseV1RecurrenceWeekComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(2);
rule1.dayTimes[0].isEnd.ShouldBeTrue();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Tuesday);
Expand All @@ -251,6 +264,7 @@ public void ParseV1RecurrenceWeekComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(2);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule2.interval.ShouldBe(30);
Expand All @@ -264,6 +278,7 @@ public void ParseV1RecurrenceMonthlyPosOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(12);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyPos);
rule1.interval.ShouldBe(1);
Expand All @@ -277,6 +292,7 @@ public void ParseV1RecurrenceMonthlyPosOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(1);
rule1.dayTimes[0].isEnd.ShouldBeFalse();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Friday);
Expand All @@ -300,6 +316,7 @@ public void ParseV1RecurrenceMonthlyPosComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(1);
rule1.dayTimes[0].isEnd.ShouldBeFalse();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Monday);
Expand All @@ -314,6 +331,7 @@ public void ParseV1RecurrenceMonthlyPosComplex()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.dayTimes.Count.ShouldBe(0);
rule2.duration.ShouldBe(10);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
Expand All @@ -336,6 +354,7 @@ public void ParseV1RecurrenceMonthlyPosComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.dayTimes.Count.ShouldBe(1);
rule1.dayTimes[0].isEnd.ShouldBeTrue();
rule1.dayTimes[0].time.ShouldBe(DayOfWeek.Monday);
Expand All @@ -349,6 +368,7 @@ public void ParseV1RecurrenceMonthlyPosComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.dayTimes.Count.ShouldBe(0);
rule2.duration.ShouldBe(10);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
Expand All @@ -370,6 +390,7 @@ public void ParseV1RecurrenceMonthlyDayOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -388,6 +409,7 @@ public void ParseV1RecurrenceMonthlyDayOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -406,6 +428,7 @@ public void ParseV1RecurrenceMonthlyDayComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(24);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -422,6 +445,7 @@ public void ParseV1RecurrenceMonthlyDayComplex()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(5);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule2.interval.ShouldBe(1);
Expand All @@ -436,6 +460,7 @@ public void ParseV1RecurrenceMonthlyDayComplex()

// Check the third rule
var rule3 = rules[2];
rule3.Version.ShouldBe(new(1, 0));
rule3.duration.ShouldBe(4);
rule3.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule3.interval.ShouldBe(15);
Expand All @@ -451,6 +476,7 @@ public void ParseV1RecurrenceMonthlyDayComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(24);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -467,6 +493,7 @@ public void ParseV1RecurrenceMonthlyDayComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(5);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule2.interval.ShouldBe(1);
Expand All @@ -481,6 +508,7 @@ public void ParseV1RecurrenceMonthlyDayComplexWithEnd()

// Check the third rule
var rule3 = rules[2];
rule3.Version.ShouldBe(new(1, 0));
rule3.duration.ShouldBe(4);
rule3.frequency.ShouldBe(RecurrenceRuleFrequency.Minute);
rule3.interval.ShouldBe(15);
Expand All @@ -496,6 +524,7 @@ public void ParseV1RecurrenceYearlyMonthOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(3);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyMonth);
rule1.interval.ShouldBe(2);
Expand All @@ -512,6 +541,7 @@ public void ParseV1RecurrenceYearlyMonthOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyMonth);
rule1.interval.ShouldBe(1);
Expand All @@ -532,6 +562,7 @@ public void ParseV1RecurrenceYearlyMonthComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(10);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyMonth);
rule1.interval.ShouldBe(1);
Expand All @@ -545,6 +576,7 @@ public void ParseV1RecurrenceYearlyMonthComplex()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.dayTimes.Count.ShouldBe(2);
rule2.dayTimes[0].isEnd.ShouldBeFalse();
rule2.dayTimes[0].time.ShouldBe(DayOfWeek.Saturday);
Expand Down Expand Up @@ -579,6 +611,7 @@ public void ParseV1RecurrenceYearlyMonthComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyMonth);
rule1.interval.ShouldBe(1);
Expand All @@ -592,6 +625,7 @@ public void ParseV1RecurrenceYearlyMonthComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(2);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.MonthlyDay);
rule2.interval.ShouldBe(1);
Expand Down Expand Up @@ -622,6 +656,7 @@ public void ParseV1RecurrenceYearlyDayOneRule()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(4);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -644,6 +679,7 @@ public void ParseV1RecurrenceYearlyDayOneRuleWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(4);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -666,6 +702,7 @@ public void ParseV1RecurrenceYearlyDayComplex()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -677,6 +714,7 @@ public void ParseV1RecurrenceYearlyDayComplex()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(5);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule2.interval.ShouldBe(1);
Expand All @@ -690,6 +728,7 @@ public void ParseV1RecurrenceYearlyDayComplexWithEnd()

// Check the first rule
var rule1 = rules[0];
rule1.Version.ShouldBe(new(1, 0));
rule1.duration.ShouldBe(5);
rule1.frequency.ShouldBe(RecurrenceRuleFrequency.YearlyDay);
rule1.interval.ShouldBe(1);
Expand All @@ -701,6 +740,7 @@ public void ParseV1RecurrenceYearlyDayComplexWithEnd()

// Check the second rule
var rule2 = rules[1];
rule2.Version.ShouldBe(new(1, 0));
rule2.duration.ShouldBe(5);
rule2.frequency.ShouldBe(RecurrenceRuleFrequency.Daily);
rule2.interval.ShouldBe(1);
Expand Down
Loading

0 comments on commit 8e7005e

Please sign in to comment.