public Example() { var olympics = new LeapYearSchedule() { Frequency = 1 }; var inauguration = new DateTime(1896, 1, 1); var from = new DateTime(2000, 12, 31); var to = new DateTime(2020, 1, 1); foreach (var d in olympics.GetOccurrences(inauguration, from).TakeWhile <DateTime>(dt => dt <= to)) { Console.WriteLine(d); } foreach (var s in Generate()) { Console.WriteLine(s.GetType().Name); // the standard formatter doesn't know about our custom schedule, so we can't call // ScheduleFormatter.Format(), and it also won't print if we use the visitor pattern // LeapYearSchedule.Accept(ScheduleFormatter()) var standard = new ScheduleFormatter(); s.Accept(standard); Console.WriteLine("Standard: {0}", standard.Description); // our extended formatter will print all existing schedules, including our custom one var extended = new ExtendedFormatter(); s.Accept(extended); Console.WriteLine("Extended: {0}", extended.Description); } }
public void TestName() { //Given var calendar = new Calendar(); var event1 = new Event("Event 1", new DateTime(2020, 10, 20), new TimeSpan(1, 0, 0)); calendar.addSchedulable(event1); var scheduleFormatter = new ScheduleFormatter(); //When var result = scheduleFormatter.format(calendar); //Then result.Should().Contain("10/20/2020 12:00:00 AM\n - Event 1 at Oct 20, 2020 12:00 AM (ends at Oct 20, 2020 1:00 AM)"); }