Exemplo n.º 1
0
        private void SerializeTest(string filename, Type iCalType)
        {
            iCalendar iCal1 = iCalendar.LoadFromFile(iCalType, @"Calendars\Serialization\" + filename);
            iCalendarSerializer serializer = new iCalendarSerializer(iCal1);

            if (!Directory.Exists(@"Calendars\Serialization\Temp"))
                Directory.CreateDirectory(@"Calendars\Serialization\Temp");

            serializer.Serialize(@"Calendars\Serialization\Temp\" + Path.GetFileNameWithoutExtension(filename) + "_Serialized.ics");
            iCalendar iCal2 = iCalendar.LoadFromFile(iCalType, @"Calendars\Serialization\Temp\" + Path.GetFileNameWithoutExtension(filename) + "_Serialized.ics");

            CompareCalendars(iCal1, iCal2);
        }
Exemplo n.º 2
0
        private void SerializeTest(string filename, Type iCalType)
        {
            if (!Directory.Exists(@"Calendars\Serialization\Temp"))
                Directory.CreateDirectory(@"Calendars\Serialization\Temp");
            
            iCalendar iCal1 = iCalendar.LoadFromFile(iCalType, @"Calendars\Serialization\" + filename);
            iCalendarSerializer serializer = new iCalendarSerializer(iCal1);

            Assert.IsTrue(iCal1.Properties.Count > 0, "iCalendar has no properties; did it load correctly?");
            Assert.IsTrue(iCal1.UniqueComponents.Count > 0, "iCalendar has no unique components; it must to be used in SerializeTest(). Did it load correctly?");            

            serializer.Serialize(@"Calendars\Serialization\Temp\" + Path.GetFileNameWithoutExtension(filename) + "_Serialized.ics");
            iCalendar iCal2 = iCalendar.LoadFromFile(iCalType, @"Calendars\Serialization\Temp\" + Path.GetFileNameWithoutExtension(filename) + "_Serialized.ics");

            CompareCalendars(iCal1, iCal2);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Create a new iCalendar
            iCalendar iCal = new iCalendar();
            
            // Create the event, and add it to the iCalendar
            Event evt = Event.Create(iCal);

            // Set information about the event
            evt.Start = DateTime.Today;
            evt.End = DateTime.Today.AddDays(1); // This also sets the duration
            evt.DTStamp = DateTime.Now;
            evt.Description = "The event description";
            evt.Location = "Event location";
            evt.Summary = "The summary of the event";
            
            // Serialize (save) the iCalendar
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"iCalendar.ics");
        }
Exemplo n.º 4
0
        /// <summary>
        /// The main program execution.
        /// </summary>
        static void Main(string[] args)
        {
            // Create a new iCalendar
            iCalendar iCal = new iCalendar();
            
            // Create the event, and add it to the iCalendar
            Event evt = Event.Create(iCal);

            // Set information about the event
            evt.Start = DateTime.Today;
            evt.Start = evt.Start.AddHours(8);
            evt.End = evt.Start.AddHours(18); // This also sets the duration            
            evt.Description = "The event description";
            evt.Location = "Event location";
            evt.Summary = "18 hour event summary";

            // Set information about the second event
            evt = Event.Create(iCal);
            evt.Start = DateTime.Today.AddDays(5);            
            evt.End = evt.Start.AddDays(1);
            evt.IsAllDay = true;            
            evt.Summary = "All-day event";

            // Display each event
            foreach(Event e in iCal.Events)
                Console.WriteLine("Event created: " + GetDescription(e));
            
            // Serialize (save) the iCalendar
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"iCalendar.ics");
            Console.WriteLine("iCalendar file saved." + Environment.NewLine);
            
            // Load the calendar from the file we just saved
            iCal = iCalendar.LoadFromFile(@"iCalendar.ics");
            Console.WriteLine("iCalendar file loaded.");

            // Iterate through each event to display its description
            // (and verify the file saved correctly)
            foreach (Event e in iCal.Events)
                Console.WriteLine("Event loaded: " + GetDescription(e));
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // Load the example iCalendar file into our CustomICalendar object
            CustomICalendar iCal = iCalendar.LoadFromFile<CustomICalendar>(@"Example4.ics");
                        
            // Set the additional information on our custom events
            Console.WriteLine("Adding additional information to each event from Example4.ics...");
            foreach(CustomEvent evt in iCal.Events)
                evt.AdditionalInformation = "Some additional information we want to save";

            // Serializer our iCalendar
            Console.WriteLine("Saving altered iCalendar to Example4_Serialized.ics...");
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Example4_Serialized.ics");

            // Load the serialized calendar from the file we just saved,
            // and display the event summary for each event, along
            // with the additional information we saved.
            Console.WriteLine("Loading Example4_Serialized.ics to display saved events...");
            iCal = iCalendar.LoadFromFile<CustomICalendar>(@"Example4_Serialized.ics");
            foreach (CustomEvent evt in iCal.Events)
                Console.WriteLine("\t" + evt.Summary + ": " + evt.AdditionalInformation);
        }
Exemplo n.º 6
0
        public void SERIALIZE20()
        {
            string iCalString = @"BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Computer\, Inc//iCal 1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
CREATED:20070404T211714Z
DTEND:20070407T010000Z
DTSTAMP:20070404T211714Z
DTSTART:20070406T230000Z
DURATION:PT2H
RRULE:FREQ=WEEKLY;UNTIL=20070801T070000Z;BYDAY=FR
SUMMARY:Friday Meetings
DTSTAMP:20040103T033800Z
SEQUENCE:1
UID:fd940618-45e2-4d19-b118-37fd7a8e3906
END:VEVENT
BEGIN:VEVENT
CREATED:20070404T204310Z
DTEND:20070416T030000Z
DTSTAMP:20070404T204310Z
DTSTART:20070414T200000Z
DURATION:P1DT7H
RRULE:FREQ=DAILY;COUNT=12;BYDAY=SA,SU
SUMMARY:Weekend Yea!
DTSTAMP:20040103T033800Z
SEQUENCE:1
UID:ebfbd3e3-cc1e-4a64-98eb-ced2598b3908
END:VEVENT
END:VCALENDAR
";
            StringReader sr = new StringReader(iCalString);
            iCalendar calendar = iCalendar.LoadFromStream(sr);

            Assert.IsTrue(calendar.Events.Count == 2, "There should be 2 events in the loaded iCalendar.");
            Assert.IsNotNull(calendar.Events["fd940618-45e2-4d19-b118-37fd7a8e3906"], "There should be an event with UID: fd940618-45e2-4d19-b118-37fd7a8e3906");
            Assert.IsNotNull(calendar.Events["ebfbd3e3-cc1e-4a64-98eb-ced2598b3908"], "There should be an event with UID: ebfbd3e3-cc1e-4a64-98eb-ced2598b3908");

            iCalendarSerializer serializer = new iCalendarSerializer(calendar);
            serializer.Serialize(@"Calendars\Serialization\SERIALIZE20.ics");

            SerializeTest("SERIALIZE20.ics", typeof(iCalendarSerializer));
        }
Exemplo n.º 7
0
        public void SERIALIZE25()
        {
            iCalendar iCal = new iCalendar();
            Event evt = iCal.Create<Event>();
            evt.Start = DateTime.Now;
            evt.Duration = TimeSpan.FromHours(1);
            evt.Summary = @"
Thank you for purchasing tickets on Ticketmaster.
Your order number for this purchase is 19-36919/UK1.

Tickets will be despatched as soon as possible, but may not be received until 7-10 days before the event. Please do not contact us unless you have not received your tickets within 7 days of the event.


You purchased 2 tickets to: 
_____________________________________________________________________________________________ 
Prince
The O2, London, UK
Fri 31 Aug 2007, 18:00 

Seat location: section BK 419, row M, seats 912-913
Total Charge: £69.42

http://ads.as4x.tmcs.ticketmaster.com/click.ng/site=tm&pagepos=531&adsize=336x102&lang=en-uk&majorcatid=10001&minorcatid=1&event_id=12003EA8AD65189AD&venueid=148826&artistid=135895&promoter=161&TransactionID=0902229695751936911UKA
Thanks again for using Ticketmaster.
Show complete  HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%35%5F%33%30%33&R=%6F%6C%5F%31%33%31&U=%31%39%2D%33%36%41%31%39%2F%55%4B%31&M=%35&B=%32%2E%30&S=%68%80%74%70%73%3A%2F%3F%77%77%77%2E%74%80%63%6B%65%71%6D%61%73%74%65%72%2E%63%6F%2E"" \t ""_blank"" order detail.
You can always check your order and manage your preferences in  HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%6F%6C%5F%6D%65%6D%62%65%72&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%73%3A%2F%2F%77%"" \t ""_blank"" My Ticketmaster. 

_____________________________________________________________________________________________

C  U  S  T  O  M  E  R      S  E  R  V  I  C  E 
_____________________________________________________________________________________________

If you have any questions regarding your booking you can search for answers using our online helpdesk at http://ticketmaster.custhelp.com

You can search our extensive range of answers and in the unlikely event that you cannot find an answer to your query, you can use 'Ask a Question' to contact us directly.



_____________________________________________________________________________________________
This email confirms your ticket order, so print/save it for future reference. All purchases are subject to credit card approval and billing address verification. We make every effort to be accurate, but we cannot be responsible for changes, cancellations, or postponements announced after this email is sent. 
Please do not reply to this email. Replies to this email will not be responded to or read. If you have any questions or comments,  HYPERLINK ""http://ntr.ticketmaster.com:80/ssp/?&C=%39%33%30%30%30%5F%33%30%33&R=%32&U=%31%39%2D%33%36%39%31%39%2F%55%4B%31&M=%31&B=%32%2E%30&S=%68%74%74%70%3A%2F%2F%77%77%77%2E%74%69%63%6B%65%74%6D%61%73%74%65%72%2E%63%6F%2E%75%6B%2F%68%2F%63%75%73%74%6F%6D%65%72%5F%73%65%72%76%65%2E%68%74%6D%6C"" \t ""_blank"" contact us.

Ticketmaster UK Limited Registration in England No 2662632, Registered Office, 48 Leicester Square, London WC2H 7LR ";

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\SERIALIZE25.ics");

            SerializeTest("SERIALIZE25.ics", typeof(iCalendarSerializer));
        }
Exemplo n.º 8
0
        public void ADDEVENT1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\GEO1.ics");
            Program.TestCal(iCal);

            Event evt = Event.Create(iCal);
            evt.Summary = "Test event";
            evt.Description = "This is an event to see if event creation works";
            evt.Start = new Date_Time(2006, 12, 15, "US-Eastern", iCal);
            evt.Duration = new TimeSpan(1, 0, 0);
            evt.Organizer = "*****@*****.**";

            if (!Directory.Exists(@"Calendars\General\Temp"))
                Directory.CreateDirectory(@"Calendars\General\Temp");

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\General\Temp\GEO1_Serialized.ics");
        }
        public void TimeZone3()
        {
            SerializeTest("TimeZone3.ics", typeof(iCalendarSerializer));

            iCalendar iCal = new iCalendar();
            IICalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars/Serialization/TimeZone3.ics")[0];
            iCal.MergeWith(tmp_cal);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/TimeZone3.ics");
        }
Exemplo n.º 10
0
        public void REQUIREDPARAMETERS1()
        {
            iCalendar iCal = new iCalendar();
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\Temp\REQUIREDPARAMETERS1.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\REQUIREDPARAMETERS1.ics");
            Assert.IsNotEmpty(iCal.Version);
            Assert.IsNotEmpty(iCal.ProductID);

            iCal.Version = string.Empty;
            iCal.ProductID = null;
            Assert.IsNotEmpty(iCal.Version, "VERSION is required");
            Assert.IsNotEmpty(iCal.ProductID, "PRODID is required");
        }
Exemplo n.º 11
0
        public void TIMEZONE2()
        {
            //
            // First, check against the VALUE parameter; it must be absent in DTSTART
            //

            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE2.ics");

            DDay.iCal.Components.TimeZone tz = iCal.TimeZones[0];
            foreach (DDay.iCal.Components.TimeZone.TimeZoneInfo tzi in tz.TimeZoneInfos)
                tzi.Start = new Date_Time(2007, 1, 1);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\Temp\TIMEZONE2.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\TIMEZONE2.ics");
            tz = iCal.TimeZones[0];

            foreach (DDay.iCal.Components.TimeZone.TimeZoneInfo tzi in tz.TimeZoneInfos)
            {
                ContentLine cl = tzi.Start.ContentLine;
                Assert.IsFalse(cl.Parameters.ContainsKey("VALUE"), "\"DTSTART\" property MUST be represented in local time in timezones");
            }

            //
            // Next, check against UTC time; DTSTART must be presented in local time
            //
            iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE2.ics");

            tz = iCal.TimeZones[0];
            foreach (DDay.iCal.Components.TimeZone.TimeZoneInfo tzi in tz.TimeZoneInfos)
                tzi.Start = DateTime.Now.ToUniversalTime();

            serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\Temp\TIMEZONE2.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\TIMEZONE2.ics");
            tz = iCal.TimeZones[0];

            foreach (DDay.iCal.Components.TimeZone.TimeZoneInfo tzi in tz.TimeZoneInfos)
            {
                ContentLine cl = tzi.Start.ContentLine;
                Assert.IsFalse(cl.Parameters.ContainsKey("VALUE"), "\"DTSTART\" property MUST be represented in local time in timezones");
            }
        }
        public void Bug3177278()
        {
            var calendar = new iCalendar();
            var serializer = new iCalendarSerializer();

            MemoryStream ms = new MemoryStream();
            serializer.Serialize(calendar, ms, Encoding.UTF8);

            Assert.IsTrue(ms.CanWrite);
        }
Exemplo n.º 13
0
        public void SERIALIZE16()
        {
            CustomICal1 iCal = new CustomICal1();
            string nonstandardText = "Some nonstandard property we want to serialize";

            CustomEvent1 evt = iCal.Create<CustomEvent1>();
            evt.Summary = "Test event";
            evt.Start = new DateTime(2007, 02, 15);
            evt.NonstandardProperty = nonstandardText;
            evt.IsAllDay = true;

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\SERIALIZE16.ics");

            iCal = iCalendar.LoadFromFile<CustomICal1>(@"Calendars\Serialization\SERIALIZE16.ics");
            foreach (CustomEvent1 evt1 in iCal.Events)
                Assert.IsTrue(evt1.NonstandardProperty.Equals(nonstandardText));

            SerializeTest("SERIALIZE16.ics", typeof(CustomICal1));
        }
        public void Attachment2()
        {
            IICalendar iCal = new iCalendar();

            // Create a test event
            IEvent evt = iCal.Create<Event>();
            evt.Summary = "Test Event";
            evt.Start = new iCalDateTime(2007, 10, 15, 8, 0, 0);
            evt.Duration = TimeSpan.FromHours(1);

            // Get a data file
            string loremIpsum = UnicodeEncoding.Default.GetString(ReadBinary(@"Data/LoremIpsum.txt"));
            StringBuilder sb = new StringBuilder();
            // If we copy it 300 times, we should end up with a file over 2.5MB in size.
            for (int i = 0; i < 300; i++)
                sb.AppendLine(loremIpsum);

            // Add an attachment to this event
            IAttachment attachment = new Attachment();
            attachment.Data = UnicodeEncoding.Default.GetBytes(sb.ToString());
            evt.Attachments.Add(attachment);

            iCalendarSerializer serializer = new iCalendarSerializer();
            if (!Directory.Exists(@"Calendars/Serialization/Temp"))
                Directory.CreateDirectory(@"Calendars/Serialization/Temp");
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/Attachment2.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Temp/Attachment2.ics")[0];
            evt = iCal.Events.First();
            attachment = evt.Attachments[0];

            // Ensure the generated and serialized strings match
            Assert.AreEqual(sb.ToString(), UnicodeEncoding.Default.GetString(attachment.Data));

            // Times to finish the test for attachment file sizes (on my computer, version 0.80): 
            //  0.92MB = 1.2 seconds
            //  2.76MB = 6 seconds
            //  4.6MB = 15.1 seconds
            //  9.2MB = 54 seconds
        }
        public void Attendee3()
        {
            IICalendar iCal = new iCalendar();
            IEvent evt = iCal.Create<Event>();

            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2010, 7, 3, 8, 0, 0);
            evt.End = new iCalDateTime(2010, 7, 3, 9, 0, 0);

            IAttendee attendee = new Attendee("mailto:[email protected]");
            attendee.Members.Add("mailto:[email protected]");
            evt.Attendees.Add(attendee);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Attendee3.ics");

            // Ensure the loaded calendar and our original are identical
            IICalendar loadedCalendar = iCalendar.LoadFromFile(@"Calendars/Serialization/Attendee3.ics")[0];
            CompareCalendars(iCal, loadedCalendar);
        }
        public void Attachment1()
        {
            IICalendar iCal = new iCalendar();

            // Create a test event
            IEvent evt = iCal.Create<Event>();
            evt.Summary = "Test Event";
            evt.Start = new iCalDateTime(2007, 10, 15, 8, 0, 0);
            evt.Duration = TimeSpan.FromHours(1);

            // Add an attachment to this event
            IAttachment attachment = new Attachment();
            attachment.Data = ReadBinary(@"Data/Test.doc");
            attachment.Parameters.Add("X-FILENAME", "WordDocument.doc");
            evt.Attachments.Add(attachment);

            iCalendarSerializer serializer = new iCalendarSerializer();
            if (!Directory.Exists(@"Calendars/Serialization/Temp"))
                Directory.CreateDirectory(@"Calendars/Serialization/Temp");
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/Attachment1.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Temp/Attachment1.ics")[0];
            evt = iCal.Events.First();
            attachment = evt.Attachments[0];

            Assert.IsTrue(CompareBinary(@"Data/Test.doc", attachment.Data), "Serialized version of Test.doc did not match the deserialized version.");
        }
        public void XProperty4()
        {
            iCalendar iCal = new iCalendar();
            iCal.AddProperty("X-WR-CALNAME", "DDay Test");
            iCal.AddProperty("X-WR-CALDESC", "Events for a DDay Test");
            iCal.AddProperty("X-PUBLISHED-TTL", "PT30M");
            iCal.ProductID = "-//DDAYTEST//NONSGML www.test.com//EN";

            // Create an event in the iCalendar
            Event evt = iCal.Create<Event>();

            // Populate the properties
            evt.Start = new iCalDateTime(2009, 6, 28, 8, 0, 0);
            evt.Duration = TimeSpan.FromHours(1);
            evt.Url = new Uri("http://www.ftb.pl/news/59941_0_1/tunnel-electrocity-2008-timetable.htm");
            evt.Summary = "This is a title";
            evt.Description = "This is a description";

            iCalendarSerializer serializer = new iCalendarSerializer();
            string output = serializer.SerializeToString(iCal);
            serializer.Serialize(iCal, @"Calendars/Serialization/XProperty4.ics");

            Assert.IsFalse(Regex.IsMatch(output, @"\r\n[\r\n]"));

            SerializeTest("XProperty4.ics", typeof(iCalendarSerializer));
        }
        public void XProperty3()
        {
            iCalendar iCal = new iCalendar();
            Event evt = iCal.Create<Event>();

            StringBuilder htmlBuilder = new StringBuilder();
            htmlBuilder.Append("<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=iso-8859-1\"></HEAD><BODY>");
            htmlBuilder.Append("<B>Test</B>");
            htmlBuilder.Append("</BODY></HTML>");
                        
            ICalendarProperty p = new CalendarProperty("X-ALT-DESC", htmlBuilder.ToString());
            p.Parameters.Add(new CalendarParameter("FMTTYPE", "text/html"));
            evt.Properties.Add(p);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/XProperty3.ics");

            SerializeTest("XProperty3.ics", typeof(iCalendarSerializer));
        }
Exemplo n.º 19
0
        public void SERIALIZE28()
        {
            iCalendar iCal = new iCalendar();
            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = DateTime.Now;
            evt.Duration = TimeSpan.FromMinutes(30);
            evt.Organizer = new Cal_Address("*****@*****.**");
            evt.AddAttendee("*****@*****.**");
            evt.AddAttendee("*****@*****.**");
            evt.AddAttendee("*****@*****.**");

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\SERIALIZE28.ics");

            SerializeTest("SERIALIZE28.ics", typeof(iCalendarSerializer));
        }
        public void Bug3211934()
        {
            var calendar = new iCalendar();
            var serializer = new iCalendarSerializer();

            var filename = "Bug3211934.ics";

            if (File.Exists(filename))
            {
                // Reset the file attributes and delete
                File.SetAttributes(filename, FileAttributes.Normal);
                File.Delete(filename);
            }

            serializer.Serialize(calendar, filename);

            // Set the file as read-only
            File.SetAttributes(filename, FileAttributes.ReadOnly);

            // Load the calendar from file, and ensure the read-only attribute doesn't affect the load
            var calendars = iCalendar.LoadFromFile(filename, Encoding.UTF8, serializer);
            Assert.IsNotNull(calendars);

            // Reset the file attributes and delete
            File.SetAttributes(filename, FileAttributes.Normal);
            File.Delete(filename);
        }
Exemplo n.º 21
0
        public void TIMEZONE3()
        {
            SerializeTest("TIMEZONE3.ics", typeof(iCalendarSerializer));

            iCalendar iCal = new iCalendar();
            iCalendar tmp_cal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE3.ics");
            iCal.MergeWith(tmp_cal);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\testMeOut.ics");
        }
        public void CalendarParameters1()
        {
            IICalendar iCal = new iCalendar();
            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/CalendarParameters1.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/CalendarParameters1.ics")[0];
            Assert.IsFalse((null == iCal.Version) || (String.Empty == iCal.Version));
            Assert.IsFalse((null == iCal.ProductID) || (String.Empty == iCal.ProductID));
        }
Exemplo n.º 23
0
        public void SERIALIZE17()
        {
            // Create a normal iCalendar, serialize it, and load it as a custom calendar
            iCalendar iCal = new iCalendar();            

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new DateTime(2007, 02, 15, 8, 0, 0);            

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\SERIALIZE17.ics");

            SerializeTest("SERIALIZE17.ics", typeof(CustomICal1));
        }
        public void TimeZone2()
        {
            //
            // First, check against the VALUE parameter; it must be absent in DTSTART
            //

            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/TimeZone2.ics")[0];

            ITimeZone tz = iCal.TimeZones[0];
            foreach (iCalTimeZoneInfo tzi in tz.TimeZoneInfos)
                tzi.Start = new iCalDateTime(2007, 1, 1);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/TimeZone2.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Temp/TimeZone2.ics")[0];
            tz = iCal.TimeZones[0];

            foreach (iCalTimeZoneInfo tzi in tz.TimeZoneInfos)
            {
                Assert.AreEqual(
                    0,
                    tzi.Properties["DTSTART"].Parameters.CountOf("VALUE"),
                    "\"DTSTART\" property MUST be represented in local time in timezones");
            }

            //
            // Next, check against UTC time; DTSTART must be presented in local time
            //
            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/TimeZone2.ics")[0];

            tz = iCal.TimeZones[0];
            foreach (iCalTimeZoneInfo tzi in tz.TimeZoneInfos)
            {
                tzi.Start = iCalDateTime.Now;
                tzi.Start.IsUniversalTime = true;
            }

            serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/TimeZone2.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Temp/TimeZone2.ics")[0];
            tz = iCal.TimeZones[0];

            foreach (iCalTimeZoneInfo tzi in tz.TimeZoneInfos)
            {
                Assert.AreEqual(0, tzi.Properties["DTSTART"].Parameters.CountOf("VALUE"),
                    "\"DTSTART\" property MUST be represented in local time in timezones");
            }
        }
Exemplo n.º 25
0
        public void TIMEZONE1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\TIMEZONE1.ics");
            
            DDay.iCal.Components.TimeZone tz = iCal.TimeZones[0];
            tz.Last_Modified = new Date_Time(2007, 1, 1);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            serializer.Serialize(@"Calendars\Serialization\Temp\TIMEZONE1.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars\Serialization\Temp\TIMEZONE1.ics");
            tz = iCal.TimeZones[0];

            ContentLine cl = tz.Last_Modified.ContentLine;
            Assert.IsFalse(cl.Parameters.ContainsKey("VALUE"), "The \"VALUE\" parameter is not allowed on \"LAST-MODIFIED\"");
        }
        public void FreeBusy1()
        {
            IICalendar iCal = new iCalendar();

            IEvent evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2010, 10, 1, 8, 0, 0);
            evt.End = new iCalDateTime(2010, 10, 1, 9, 0, 0);

            IICalendar freeBusyCalendar = new iCalendar();
            IFreeBusy freeBusy = iCal.GetFreeBusy(new iCalDateTime(2010, 10, 1, 0, 0, 0), new iCalDateTime(2010, 10, 7, 11, 59, 59));
            freeBusyCalendar.AddChild(freeBusy);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(freeBusyCalendar, @"Calendars/Serialization/FreeBusy1.ics");

            SerializeTest("FreeBusy1.ics", typeof(iCalendarSerializer));
        }
        public void TimeZone1()
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/TimeZone1.ics")[0];

            ITimeZone tz = iCal.TimeZones[0];
            tz.LastModified = new iCalDateTime(2007, 1, 1);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Temp/TimeZone1.ics");

            iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Temp/TimeZone1.ics")[0];
            tz = iCal.TimeZones[0];

            Assert.AreEqual(0, tz.Properties["LAST-MODIFIED"].Parameters.CountOf("VALUE"), "The \"VALUE\" parameter is not allowed on \"LAST-MODIFIED\"");
        }
        public void FreeBusy2()
        {
            IICalendar iCal = new iCalendar();

            IEvent evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2010, 10, 1, 8, 0, 0);
            evt.End = new iCalDateTime(2010, 10, 1, 9, 0, 0);

            IAttendee attendee = new Attendee("mailto:[email protected]");
            attendee.ParticipationStatus = ParticipationStatus.Tentative;
            evt.Attendees.Add(attendee);

            IICalendar freeBusyCalendar = new iCalendar();
            IFreeBusy freeBusy = iCal.GetFreeBusy(
                null, 
                new IAttendee[] { new Attendee("mailto:[email protected]") }, 
                new iCalDateTime(2010, 10, 1, 0, 0, 0), 
                new iCalDateTime(2010, 10, 7, 11, 59, 59));

            freeBusyCalendar.AddChild(freeBusy);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(freeBusyCalendar, @"Calendars/Serialization/FreeBusy2.ics");

            SerializeTest("FreeBusy2.ics", typeof(iCalendarSerializer));
        }
        public void Event5()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new iCalDateTime(2007, 3, 19);
            evt.Start.IsUniversalTime = true;
            evt.Duration = new TimeSpan(24, 0, 0);
            evt.Created = evt.Start.Copy<IDateTime>();
            evt.DTStamp = evt.Start.Copy<IDateTime>();
            evt.UID = "123456789";
            evt.IsAllDay = true;

            RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.RecurrenceRules.Add(rec);

            iCalendarSerializer serializer = new iCalendarSerializer();
            string icalString = serializer.SerializeToString(iCal);

            Assert.IsFalse(String.Empty == icalString, "iCalendarSerializer.SerializeToString() must not be empty");

            EventSerializer eventSerializer = new EventSerializer();
            string evtString = eventSerializer.SerializeToString(evt);

            var target = "BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND;VALUE=DATE:20070320\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSEQUENCE:0\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n";
            Assert.AreEqual(target, evtString, "ComponentBaseSerializer.SerializeToString() serialized incorrectly");

            serializer.Serialize(iCal, @"Calendars/Serialization/Event5.ics");
            SerializeTest("Event5.ics", typeof(iCalendarSerializer));
        }
        public void Alarm1()
        {
            // Create a new iCalendar
            iCalendar iCal = new iCalendar();

            // Create the event, and add it to the iCalendar
            Event evt = iCal.Create<Event>();

            evt.Start = new iCalDateTime(2010, 7, 3, 8, 0, 0);
            evt.End = evt.Start.AddHours(1);
            evt.Summary = "Test event";
            evt.Description = "Some description";

            Alarm alarm = new Alarm();
            alarm.Action = AlarmAction.Display;
            alarm.Summary = "Alarm for the first Monday and second-to-last Monday of each month";
            alarm.Trigger = new Trigger(TimeSpan.FromMinutes(-30));
            alarm.Repeat = 2;
            alarm.Duration = TimeSpan.FromMinutes(10);

            // Add the alarm to the event
            evt.Alarms.Add(alarm);

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.Serialize(iCal, @"Calendars/Serialization/Alarm1.ics");

            IICalendar loadedCalendar = iCalendar.LoadFromFile(@"Calendars/Serialization/Alarm1.ics")[0];
            CompareCalendars(iCal, loadedCalendar);
        }