public void Defaults() { var calendar = new VCalendar(); Assert.AreEqual("Sepia.Calendaring", calendar.ProductId); Assert.AreEqual("2.0", calendar.Version); Assert.AreEqual("GREGORIAN", calendar.Scale); }
public void Reading() { const string ics = "BEGIN:VCALENDAR" + Crlf + "VERSION:2.0" + Crlf + "BEGIN:VJOURNAL" + Crlf + "UID:[email protected]" + Crlf + "DTSTAMP:19970901T130000Z" + Crlf + "DTSTART;VALUE=DATE:19970317" + Crlf + "SUMMARY:Staff meeting minutes" + Crlf + @"DESCRIPTION:1. Staff meeting\n2. Meeting with ABC Corp." + Crlf + "ATTACH;FMTTYPE=audio/basic:ftp://example.com/pub/sounds/bell-01.aud" + Crlf + "RELATED-TO:[email protected]" + Crlf + "END:VJOURNAL" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); var journal = calendar.Components.OfType<VJournal>().First(); Assert.AreEqual("*****@*****.**", journal.Id); Assert.AreEqual(new DateTime(1997, 09, 01, 13, 00, 00, DateTimeKind.Utc), journal.CreatedOnByAgent.Value); Assert.AreEqual(new DateTime(1997, 03, 17), journal.StartsOn.Value.Value); Assert.AreEqual("Staff meeting minutes", journal.Summary); Assert.AreEqual("1. Staff meeting" + Environment.NewLine + "2. Meeting with ABC Corp.", journal.Description[0]); Assert.AreEqual("audio/basic", journal.Attachments[0].ContentType); Assert.AreEqual("ftp://example.com/pub/sounds/bell-01.aud", journal.Attachments[0].Uri); Assert.AreEqual(1, journal.Relationships.Count, "missing relationship"); Assert.AreEqual("*****@*****.**", journal.Relationships[0].OtherUri); }
public void Reading() { const string ics = "BEGIN:VCALENDAR" + Crlf + "VERSION:2.0" + Crlf + "BEGIN:VTODO" + Crlf + "UID:[email protected]" + Crlf + "DTSTAMP:20070514T103211Z" + Crlf + "DTSTART:20070514T110000Z" + Crlf + "DUE:20070709T130000Z" + Crlf + "COMPLETED:20070707T100000Z" + Crlf + "SUMMARY:Submit Revised Internet-Draft" + Crlf + "PRIORITY:1" + Crlf + "CATEGORIES:WORK,IETF" + Crlf + "STATUS:NEEDS-ACTION" + Crlf + "END:VTODO" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); var todo = calendar.Components.OfType<VTodo>().First(); Assert.AreEqual("*****@*****.**", todo.Id); Assert.AreEqual(new DateTime(2007, 05, 14, 10, 32, 11, DateTimeKind.Utc), todo.CreatedOnByAgent.Value); Assert.AreEqual(new DateTime(2007, 05, 14, 11, 00, 00, DateTimeKind.Utc), todo.StartsOn.Value.Value); Assert.AreEqual(new DateTime(2007, 07, 09, 13, 00, 00, DateTimeKind.Utc), todo.DueOn.Value.Value); //TODO Assert.AreEqual("", todo.CompletedOn.Value); // TODO: percent Assert.AreEqual("Submit Revised Internet-Draft", todo.Summary); Assert.AreEqual(1, todo.Priority); Assert.AreEqual(2, todo.Categories.Count); Assert.AreEqual(TodoStatus.NeedsAction, todo.Status); }
public void Reading() { var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(Simple))); Assert.AreEqual("Zimbra-Calendar-Provider", calendar.ProductId); Assert.AreEqual("2.0", calendar.Version); Assert.AreEqual("GREGORIAN", calendar.Scale); Assert.AreEqual("REQUEST", calendar.Method); }
public void Reading() { var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(Simple))); var tz = calendar.Components.OfType<VTimeZone>().First(); Assert.AreEqual("Pacific/Wellington", tz.Id); Assert.AreEqual(new DateTime(2005, 8, 9, 5, 0, 0, 0, DateTimeKind.Utc), tz.ModifiedOn.Value.Value); Assert.IsTrue(tz.Adjustments.OfType<StandardChange>().Any()); Assert.IsTrue(tz.Adjustments.OfType<DaylightChange>().Any()); }
public void PropertiesAreCaseInsensitive() { string ics = "begin:vcalendar" + Crlf + "calscale:coptic" + Crlf + "method:request" + Crlf + "prodid:sepia" + Crlf + "version:2.0" + Crlf + "end:vcalendar" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); Assert.AreEqual("request", calendar.Method); Assert.AreEqual("sepia", calendar.ProductId); Assert.AreEqual("coptic", calendar.Scale); Assert.AreEqual("2.0", calendar.Version); }
public void Reading() { var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(Simple))); var tz = calendar.Components.OfType<VTimeZone>().First(); var winter = tz.Adjustments.OfType<StandardChange>().First(); Assert.AreEqual("NZST", winter.Name); Assert.AreEqual(new DateTime(1971, 01, 01, 03, 00, 00), winter.StartsOn); Assert.AreEqual(new TimeSpan(12, 0, 0), winter.OffsetTo); Assert.AreEqual(new TimeSpan(13, 0, 0), winter.OffsetFrom); var summer = tz.Adjustments.OfType<DaylightChange>().First(); Assert.AreEqual("NZDT", summer.Name); Assert.AreEqual(new DateTime(1971, 01, 01, 02, 00, 00), summer.StartsOn); Assert.AreEqual("'Bout time mate", summer.Comment["en-AU"].Value); Assert.AreEqual("Sweet as", summer.Comment["en-NZ"].Value); }
public void WritingComponents() { var calendar = new VCalendar() { Components = { new VTimeZone(), new VEvent() } }; var ics = new StringWriter(); calendar.WriteIcs(IcsWriter.Create(ics)); StringAssert.Contains(ics.ToString(), "BEGIN:VTIMEZONE"); StringAssert.Contains(ics.ToString(), "BEGIN:VEVENT"); }
public void WritingAllProperties() { string ics = "BEGIN:VCALENDAR" + Crlf + "CALSCALE:Coptic" + Crlf + "METHOD:REQUEST" + Crlf + "PRODID:sepia" + Crlf + "VERSION:2.0" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); var ics2 = new StringWriter(); calendar.WriteIcs(IcsWriter.Create(ics2)); Assert.AreEqual(ics, ics2.ToString()); }
public void Writing() { var c0 = new VCalendar(); c0.ReadIcs(IcsReader.Create(new StringReader(Simple))); var tz0 = c0.Components.OfType<VTimeZone>().First(); var ics = new StringWriter(); c0.WriteIcs(IcsWriter.Create(ics)); var c1 = new VCalendar(); c1.ReadIcs(IcsReader.Create(new StringReader(ics.ToString()))); var tz1 = c1.Components.OfType<VTimeZone>().First(); var standard1 = tz1.Adjustments.OfType<StandardChange>().First(); var daylight1 = tz1.Adjustments.OfType<DaylightChange>().First(); Assert.AreEqual(tz0.Id, tz1.Id); Assert.AreEqual(tz0.ModifiedOn.Value, tz1.ModifiedOn.Value); Assert.AreEqual(tz0.Uri, tz1.Uri); Assert.AreEqual(tz0.Adjustments.Count, tz1.Adjustments.Count); Assert.IsTrue(tz1.Adjustments.OfType<StandardChange>().Any()); Assert.IsTrue(tz1.Adjustments.OfType<DaylightChange>().Any()); }
public void Writing() { const string ics0 = "BEGIN:VCALENDAR" + Crlf + "VERSION:2.0" + Crlf + "BEGIN:VTODO" + Crlf + "UID:[email protected]" + Crlf + "DTSTAMP:20070514T103211Z" + Crlf + "DTSTART:20070514T110000Z" + Crlf + "DUE:20070709T130000Z" + Crlf + "COMPLETED:20070707T100000Z" + Crlf + "SUMMARY:Submit Revised Internet-Draft" + Crlf + "PRIORITY:1" + Crlf + "CATEGORIES:WORK,IETF" + Crlf + "STATUS:NEEDS-ACTION" + Crlf + "BEGIN:VALARM" + Crlf + "TRIGGER;RELATED=END:-P2D" + Crlf + "ACTION:EMAIL" + Crlf + "ATTENDEE:mailto:[email protected]" + Crlf + "SUMMARY:*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING ***" + Crlf + "DESCRIPTION:A draft agenda needs to be sent out to the attendees " + Crlf + " to the weekly managers meeting (MGR-LIST). Attached is a " + Crlf + " pointer the document template for the agenda file." + Crlf + "ATTACH;FMTTYPE=application/msword:http://example.com/" + Crlf + " templates/agenda.doc" + Crlf + "END:VALARM" + Crlf + "END:VTODO" + Crlf + "END:VCALENDAR" + Crlf; var calendar0 = new VCalendar(); calendar0.ReadIcs(IcsReader.Create(new StringReader(ics0))); var ics = new StringWriter(); calendar0.WriteIcs(IcsWriter.Create(ics)); Console.WriteLine(ics.ToString()); var calendar1 = new VCalendar(); calendar1.ReadIcs(IcsReader.Create(new StringReader(ics.ToString()))); var todo = calendar1.Components.OfType<VTodo>().First(); Assert.AreEqual("*****@*****.**", todo.Id); Assert.AreEqual(new DateTime(2007, 05, 14, 10, 32, 11, DateTimeKind.Utc), todo.CreatedOnByAgent.Value); Assert.AreEqual(new DateTime(2007, 05, 14, 11, 00, 00, DateTimeKind.Utc), todo.StartsOn.Value.Value); Assert.AreEqual(new DateTime(2007, 07, 09, 13, 00, 00, DateTimeKind.Utc), todo.DueOn.Value.Value); //TODO Assert.AreEqual("", todo.CompletedOn.Value); // TODO: percent Assert.AreEqual("Submit Revised Internet-Draft", todo.Summary); Assert.AreEqual(1, todo.Priority); Assert.AreEqual(2, todo.Categories.Count); Assert.AreEqual(TodoStatus.NeedsAction, todo.Status); Assert.IsNotNull(todo.Alarm, "missing alarm"); }
public void ReadingWithAlarm() { const string ics = "BEGIN:VCALENDAR" + Crlf + "VERSION:2.0" + Crlf + "BEGIN:VEVENT" + Crlf + "UID:[email protected]" + Crlf + "DTSTAMP:19970610T172345Z" + Crlf + "DTSTART:19970714T170000Z" + Crlf + "DTEND:19970715T040000Z" + Crlf + "BEGIN:VALARM" + Crlf + "TRIGGER;VALUE=DATE-TIME:19970317T133000Z" + Crlf + "REPEAT:4" + Crlf + "DURATION:PT15M" + Crlf + "ACTION:AUDIO" + Crlf + "ATTACH;FMTTYPE=audio/basic:ftp://example.com/pub/sounds/bell-01.aud" + Crlf + "END:VALARM" + Crlf + "END:VEVENT" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); var meeting = calendar.Components.OfType<VEvent>().First(); Assert.IsNotNull(meeting.Alarm, "missing alarm"); }
public void ReadingDuration() { var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(SimpleDuration))); var meeting = calendar.Components.OfType<VEvent>().First(); Assert.AreEqual("*****@*****.**", meeting.Id); Assert.AreEqual("Bastille Day Party", meeting.Summary); Assert.AreEqual(LanguageTag.Unspecified, meeting.Summary.Language); Assert.AreEqual(new DateTime(1997, 7, 14, 17, 0, 0, DateTimeKind.Utc), meeting.StartsOn.Value.Value); Assert.IsTrue(meeting.Duration.HasValue); Assert.AreEqual(new TimeSpan(3, 0, 0), meeting.Duration); }
public void Reading() { var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(Simple))); var meeting = calendar.Components.OfType<VEvent>().First(); Assert.AreEqual("*****@*****.**", meeting.Id); Assert.AreEqual("Bastille Day Party", meeting.Summary); Assert.AreEqual(LanguageTag.Unspecified, meeting.Summary.Language); Assert.AreEqual(new DateTime(1997, 7, 14, 17, 0, 0, DateTimeKind.Utc), meeting.StartsOn.Value.Value); Assert.AreEqual(new DateTime(1997, 7, 15, 4, 0, 0, DateTimeKind.Utc), meeting.EndsOn.Value.Value); Assert.IsTrue(meeting.Categories.Any(c => c.Name == "EDUCATION")); Assert.IsTrue(meeting.Categories.Any(c => c.Name == "APPOINTMENT")); Assert.IsFalse(meeting.Categories.Any(c => c.Name == "PERSONAL")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "EASEL")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "PROJECTOR")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "VCR")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "Nettoyeur haute pression" && r.Language.Name == "fr")); Assert.IsNull(meeting.Alarm, "no alarm"); }
public void ReadingMultilingualText() { const string ics = "BEGIN:VCALENDAR" + Crlf + "VERSION:2.0" + Crlf + "BEGIN:VJOURNAL" + Crlf + "UID:[email protected]" + Crlf + "DTSTAMP:19970901T130000Z" + Crlf + "SUMMARY:hello" + Crlf + "DESCRIPTION:hello" + Crlf + "DESCRIPTION;LANGUAGE=en:hi" + Crlf + "DESCRIPTION;LANGUAGE=en-nz:cheers" + Crlf + "END:VJOURNAL" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); var journal = calendar.Components.OfType<VJournal>().First(); Assert.AreEqual("hi", journal.Description.WrittenIn("en")); Assert.AreEqual("cheers", journal.Description.WrittenIn("en-nz")); Assert.AreEqual("hello", journal.Description.WrittenIn(LanguageTag.Unspecified)); }
public void ReadingAllProperties() { string ics = "BEGIN:VCALENDAR" + Crlf + "CALSCALE:Coptic" + Crlf + "METHOD:REQUEST" + Crlf + "PRODID:sepia" + Crlf + "VERSION:2.0" + Crlf + "END:VCALENDAR" + Crlf; var calendar = new VCalendar(); calendar.ReadIcs(IcsReader.Create(new StringReader(ics))); Assert.AreEqual("REQUEST", calendar.Method); Assert.AreEqual("sepia", calendar.ProductId); Assert.AreEqual("Coptic", calendar.Scale); Assert.AreEqual("2.0", calendar.Version); }
public void Writing() { var calendar0 = new VCalendar(); calendar0.ReadIcs(IcsReader.Create(new StringReader(Full))); var ics = new StringWriter(); calendar0.WriteIcs(IcsWriter.Create(ics)); //Console.WriteLine(ics.ToString()); var calendar1 = new VCalendar(); calendar1.ReadIcs(IcsReader.Create(new StringReader(ics.ToString()))); var meeting = calendar1.Components.OfType<VEvent>().First(); Assert.AreEqual("*****@*****.**", meeting.Id); Assert.AreEqual("Bastille Day Party", meeting.Summary); Assert.AreEqual(LanguageTag.Unspecified, meeting.Summary.Language); Assert.AreEqual(new DateTime(1997, 7, 14, 17, 0, 0, DateTimeKind.Utc), meeting.StartsOn.Value.Value); Assert.AreEqual(new DateTime(1997, 7, 15, 4, 0, 0, DateTimeKind.Utc), meeting.EndsOn.Value.Value); Assert.IsTrue(meeting.Categories.Any(c => c.Name == "EDUCATION")); Assert.IsTrue(meeting.Categories.Any(c => c.Name == "APPOINTMENT")); Assert.IsFalse(meeting.Categories.Any(c => c.Name == "PERSONAL")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "EASEL")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "PROJECTOR")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "VCR")); Assert.IsTrue(meeting.Resources.Any(r => r.Value == "Nettoyeur haute pression" && r.Language.Name == "fr")); Assert.AreEqual("John Smith", meeting.Organizer.DisplayName); Assert.AreEqual("*****@*****.**", meeting.Organizer.Address); Assert.IsNotNull(meeting.Alarm, "missing alarm"); Assert.AreEqual(1, meeting.Attendees.Count, "missing the attendee"); Assert.AreEqual(2, meeting.Revision); Assert.AreEqual(EventStatus.Tentative, meeting.Status); Assert.IsTrue(meeting.IsTransparent); Assert.AreEqual(37.386013d, meeting.GlobalPosition.Latitude); Assert.AreEqual(-122.082932d, meeting.GlobalPosition.Longitude); Assert.AreEqual(1, meeting.Contacts.Count, "missing contact"); Assert.AreEqual("http://host.com/pdi/jdoe.vcf", meeting.Contacts[0].Uri); Assert.AreEqual("Jim Dolittle, ABC Industries, +1-919-555-1234", meeting.Contacts[0].Text); Assert.AreEqual("audio/basic", meeting.Attachments[0].ContentType); Assert.AreEqual("ftp://example.com/pub/sounds/bell-01.aud", meeting.Attachments[0].Uri); Assert.AreEqual("application/msword", meeting.Attachments[1].ContentType); Assert.AreEqual("http://example.com/templates/agenda.doc", meeting.Attachments[1].Uri); Assert.AreEqual(1, meeting.Relationships.Count, "missing relationship"); Assert.AreEqual("*****@*****.**", meeting.Relationships[0].OtherUri); Assert.AreEqual(1, meeting.RequestStatuses.Count, "missing request statuses"); Assert.AreEqual("2.8", meeting.RequestStatuses[0].Code); Assert.AreEqual("Success, repeating event ignored. Scheduled as a single event.", meeting.RequestStatuses[0].Description); Assert.AreEqual(LanguageTag.Unspecified, meeting.RequestStatuses[0].Description.Language); Assert.AreEqual("RRULE:FREQ=WEEKLY;INTERVAL=2", meeting.RequestStatuses[0].RelatedData); Assert.IsTrue(meeting.RequestStatuses[0].IsSuccess); }