예제 #1
0
        public void GetDaysListTest()
        {
            var expected = _exampleDaysList;
            var result   = PdfParser.GetDaysList(ExampleRawInput);

            Assert.AreEqual(expected, result);
        }
예제 #2
0
        public static string GenerateCalendar(string rawInput)
        {
            ValidateInput(rawInput);
            var daysList = PdfParser.GetDaysList(rawInput);
            var events   =
                daysList.SelectMany(day => day.GetLessonTexts()).Select(text => text.ToCalendarEvent());

            var calendar = new StringBuilder();

            calendar.AppendLine("BEGIN:VCALENDAR");
            calendar.AppendLine("VERSION:2.0");
            calendar.AppendLine("PRODID:Schedule_generated_with_itext7");
            calendar.AppendLine("CALSCALE:GREGORIAN");

            events.ToList().ForEach(ev =>
            {
                calendar.AppendLine("BEGIN:VEVENT");
                calendar.AppendLine("DTSTAMP:" + FormatDateTime(ev.TimeStamp));
                calendar.AppendLine("DTSTART:" + FormatDateTime(ev.Start));
                calendar.AppendLine("DTEND:" + FormatDateTime(ev.End));
                calendar.AppendLine("SUMMARY:" + ev.Summary);
                calendar.AppendLine("DESCRIPTION:" + ev.Description);
                calendar.AppendLine("LOCATION:" + ev.Location);
                calendar.AppendLine("UID:" + ev.Uid);
                calendar.AppendLine("END:VEVENT");
            });

            calendar.AppendLine("END:VCALENDAR");
            return(calendar.ToString());
        }