public void 每2日_無獲取開始時間_有截止時間() { var recurrenceRule = new RecurrenceDaily(new DateTimeOffset(2020, 10, 10, 0, 0, 0, TimeSpan.FromHours(8)), 2, new[] { 8 * 60, 12 * 60, 16 * 60 }); var actual = recurrenceRule.GetOccurrences(endTime: new DateTimeOffset(2020, 10, 11, 10, 0, 0, TimeSpan.FromHours(8))).ToArray(); var expectations = new[] { new DateTimeOffset(2020, 10, 10, 8, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 10, 12, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 10, 16, 0, 0, TimeSpan.FromHours(8)) }; actual.Should().BeEquivalentTo(expectations); }
public void 每1日_獲取時間晚於排程開始時間_無截止時間() { var recurrenceRule = new RecurrenceDaily(new DateTimeOffset(2020, 10, 10, 0, 0, 0, TimeSpan.FromHours(8)), 1, new[] { 8 * 60, 12 * 60, 16 * 60 }); var actual = recurrenceRule.GetOccurrences( new DateTimeOffset(2020, 10, 10, 12, 0, 0, TimeSpan.FromHours(8))) .Take(6) .ToArray(); var expectations = new[] { new DateTimeOffset(2020, 10, 10, 12, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 10, 16, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 11, 8, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 11, 12, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 11, 16, 0, 0, TimeSpan.FromHours(8)), new DateTimeOffset(2020, 10, 12, 8, 0, 0, TimeSpan.FromHours(8)) }; actual.Should().BeEquivalentTo(expectations); }