public void ReadingAudio() { const string ics = "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; var alarm = new VAlarm(); alarm.ReadIcs(IcsReader.Create(new StringReader(ics))); Assert.AreEqual(AlarmAction.Audio, alarm.Action); Assert.AreEqual(new DateTime(1997, 03, 17, 13, 30, 00, DateTimeKind.Utc), alarm.TriggerOn); Assert.AreEqual(new TimeSpan(0, 0, 15, 0), alarm.Duration); Assert.AreEqual("audio/basic", alarm.Attachment.ContentType); Assert.AreEqual("ftp://example.com/pub/sounds/bell-01.aud", alarm.Attachment.Uri); Assert.AreEqual(4, alarm.Repeat); }
public void ReadingDisplay() { const string ics = "BEGIN:VALARM" + Crlf + "TRIGGER:-PT30M" + Crlf + "REPEAT:2" + Crlf + "DURATION:PT15M" + Crlf + "ACTION:DISPLAY" + Crlf + @"DESCRIPTION:Breakfast meeting with executive\n" + Crlf + " team at 8:30 AM EST." + Crlf + "END:VALARM" + Crlf; var alarm = new VAlarm(); alarm.ReadIcs(IcsReader.Create(new StringReader(ics))); Assert.AreEqual(AlarmAction.Display, alarm.Action); Assert.AreEqual(TimeSpan.FromMinutes(-30), alarm.TriggerDuration); Assert.AreEqual(TriggerEdge.Start, alarm.TriggerEdge); Assert.AreEqual(new TimeSpan(0, 0, 15, 0), alarm.Duration); Assert.AreEqual(2, alarm.Repeat); Assert.AreEqual("Breakfast meeting with executive" + Environment.NewLine + "team at 8:30 AM EST.", alarm.Description); }
/// <inheritdoc/> public void ReadIcs(IcsReader reader) { ContentLine content; while (null != (content = reader.ReadContentLine())) { switch (content.Name.ToLowerInvariant()) { case "end": if (!content.Value.Equals(Component.Names.Event, StringComparison.InvariantCultureIgnoreCase)) throw new CalendarException(String.Format("Expected 'END:{0}' not '{1}'.", Component.Names.Event, content)); return; case "begin": switch (content.Value.ToUpperInvariant()) { case Component.Names.Alarm: Alarm = new VAlarm(); Alarm.ReadIcs(reader); break; default: throw new CalendarException(string.Format("'{0}' is not a component of an event.", content.Value)); } break; case "attach": Attachments.Add(new CalendarAttachment(content)); break; case "class": Classification = content.ToTag<AccessClassification>(); break; case "comment": Comment.Add(content.ToText()); break; case "created": CreatedOn = content.ToDate(); break; case "dtstamp": CreatedOnByAgent = content.ToDate(); break; case "description": Description = content.ToText(); break; case "duration": Duration = content.ToTimeSpan(); break; case "dtend": EndsOn = content.ToDate(); break; case "geo": GlobalPosition = content.ToGeoCoordinate(); break; case "uid": Id = content.Value; break; case "transp": IsTransparent = content.ToBoolean("TRANSPARENT", "OPAQUE"); break; case "location": Location = content.ToText(); break; case "last-modified": ModifiedOn = content.ToDate(); break; case "organizer": Organizer = content.ToMailAddress(); break; case "exdate": ExcludedDates.AddRange(content.ToRecurrenceDates()); break; case "rdate": RecurrenceDates.AddRange(content.ToRecurrenceDates()); break; case "rrule": RecurrenceRule = RecurrenceRule.Parse(content.Value); break; case "sequence": Revision = content.ToInt32(); break; case "dtstart": StartsOn = content.ToDate(); break; case "recurrence-id": RecurrenceId = content.ToDate(); break; case "summary": Summary = content.ToText(); break; case "status": Status = content.ToTag<EventStatus>(); break; case "url": Uri = content.Value; break; case "categories": Categories.AddRange(content.ToTags<Tag>()); break; case "request-status": RequestStatuses.Add(new RequestStatus(content)); break; case "attendee": Attendees.Add(new Attendee(content)); break; case "contact": Contacts.Add(new Contact(content)); break; case "resources": Resources.AddRange(content.ToTextEnumerable()); break; case "related-to": Relationships.Add(new RelationshipReference(content)); break; case "priority": Priority = content.ToInt32(); break; } } throw new CalendarException("Unexpected end of file."); }
public void ReadingEmail() { const string ics = "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; var alarm = new VAlarm(); alarm.ReadIcs(IcsReader.Create(new StringReader(ics))); Assert.AreEqual(TimeSpan.FromDays(-2), alarm.TriggerDuration); Assert.AreEqual(TriggerEdge.End, alarm.TriggerEdge); Assert.AreEqual(AlarmAction.Email, alarm.Action); Assert.AreEqual("*****@*****.**", alarm.Attendees.First().MailAddress.Address); Assert.AreEqual("*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING ***", alarm.Summary); Assert.AreEqual("A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file.", alarm.Description); Assert.AreEqual("application/msword", alarm.Attachment.ContentType); Assert.AreEqual("http://example.com/templates/agenda.doc", alarm.Attachment.Uri); }
public void TriggerOnMustUtcRelative() { var alarm = new VAlarm(); ExceptionAssert.Throws<ArgumentException>(() => alarm.TriggerOn = DateTime.Now); }