Exemple #1
0
        public void TestTodoActive(string calendar, ArrayList items, params int[] numPeriods)
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar);

            ProgramTest.TestCal(iCal);
            DDay.iCal.Components.Todo todo = (DDay.iCal.Components.Todo)iCal.Todos[0];

            for (int i = 0; i < items.Count; i += 2)
            {
                iCalDateTime dt = (iCalDateTime)items[i];
                dt.iCalendar = iCal;
                dt.TZID      = tzid;

                bool tf = (bool)items[i + 1];
                if (tf)
                {
                    Assert.IsTrue(todo.IsActive(dt), "Todo should be active at " + dt);
                }
                else
                {
                    Assert.IsFalse(todo.IsActive(dt), "Todo should not be active at " + dt);
                }
            }

            if (numPeriods != null &&
                numPeriods.Length > 0)
            {
                Assert.AreEqual(
                    numPeriods[0],
                    todo.Periods.Count,
                    "Todo should have " + numPeriods[0] + " occurrences after evaluation; it had " + todo.Periods.Count);
            }
        }
Exemple #2
0
        public void Journal2()
        {
            var iCal = iCalendar.LoadFromFile(@"Calendars\Journal\JOURNAL2.ics")[0];

            ProgramTest.TestCal(iCal);
            Assert.AreEqual(1, iCal.Journals.Count);
            var j = iCal.Journals.First();

            Assert.IsNotNull(j, "Journal entry was null");
            Assert.AreEqual(JournalStatus.Final, j.Status, "Journal entry should have been in FINAL status, but it was in " + j.Status + " status.");
            Assert.AreEqual("PRIVATE", j.Class, "Journal class should have been PRIVATE, but was " + j.Class + ".");
            Assert.AreEqual("JohnSmith", j.Organizer.CommonName, "Organizer common name should have been JohnSmith, but was " + j.Organizer.CommonName);
            Assert.IsTrue(
                string.Equals(
                    j.Organizer.SentBy.OriginalString,
                    "mailto:[email protected]",
                    StringComparison.InvariantCultureIgnoreCase),
                "Organizer should have had been SENT-BY 'mailto:[email protected]'; it was sent by '" + j.Organizer.SentBy + "'");
            Assert.IsTrue(
                string.Equals(
                    j.Organizer.DirectoryEntry.OriginalString,
                    "ldap://host.com:6666/o=3DDC%20Associates,c=3DUS??(cn=3DJohn%20Smith)",
                    StringComparison.InvariantCultureIgnoreCase),
                "Organizer's directory entry should have been 'ldap://host.com:6666/o=3DDC%20Associates,c=3DUS??(cn=3DJohn%20Smith)', but it was '" + j.Organizer.DirectoryEntry + "'");
            Assert.AreEqual(
                "MAILTO:[email protected]",
                j.Organizer.Value.OriginalString);
            Assert.AreEqual(
                "jsmith",
                j.Organizer.Value.UserInfo);
            Assert.AreEqual(
                "host.com",
                j.Organizer.Value.Host);
            Assert.IsNull(j.Start);
        }
Exemple #3
0
        public void UID1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\BINARY.ics");

            ProgramTest.TestCal(iCal);

            Event evt = iCal.Events["uuid1153170430406"];

            Assert.IsNotNull(evt, "Event could not be accessed by UID");
        }
Exemple #4
0
        public void BASE64_1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\BASE64_1.ics");

            ProgramTest.TestCal(iCal);
            Event evt = iCal.Events[0];

            Assert.IsTrue(evt.UID.Value == "uuid1153170430406", "UID should be 'uuid1153170430406'; it is " + evt.UID.Value);
            Assert.IsTrue(evt.Sequence.Value == 1, "SEQUENCE should be 1; it is " + evt.Sequence.Value);
        }
Exemple #5
0
        public void GEO1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\GEO1.ics");

            ProgramTest.TestCal(iCal);
            Event evt = iCal.Events[0];

            Assert.IsTrue(evt.Geo.Latitude.Value == 37.386013, "Latitude should be 37.386013; it is not.");
            Assert.IsTrue(evt.Geo.Longitude.Value == -122.082932, "Longitude should be -122.082932; it is not.");
        }
Exemple #6
0
        public void LoadFromFile()
        {
            string path = @"Calendars\General\Test1.ics";

            Assert.IsTrue(File.Exists(path), "File '" + path + "' does not exist.");

            iCalendar iCal = iCalendar.LoadFromFile(path);

            ProgramTest.TestCal(iCal);
        }
Exemple #7
0
        public void LoadFromUri()
        {
            string path = Directory.GetCurrentDirectory();

            path = Path.Combine(path, "Calendars/General/Test1.ics").Replace(@"\", "/");
            path = "file:///" + path;
            Uri       uri  = new Uri(path);
            iCalendar iCal = iCalendar.LoadFromUri(uri);

            ProgramTest.TestCal(iCal);
        }
Exemple #8
0
        public void JOURNAL1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Journal\JOURNAL1.ics");

            ProgramTest.TestCal(iCal);
            DDay.iCal.Components.Journal j = (DDay.iCal.Components.Journal)iCal.Journals[0];

            Assert.IsNotNull(j, "Journal entry was null");
            Assert.IsTrue(j.Status == JournalStatus.Draft, "Journal entry should have been in DRAFT status, but it was in " + j.Status.ToString() + " status.");
            Assert.IsTrue(j.Class.Value == "PUBLIC", "Journal class should have been PUBLIC, but was " + j.Class + ".");
            Assert.IsNull(j.DTStart);
        }
        public void Journal1()
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars\Journal\JOURNAL1.ics")[0];

            ProgramTest.TestCal(iCal);
            Assert.AreEqual(1, iCal.Journals.Count);
            IJournal j = iCal.Journals[0];

            Assert.IsNotNull(j, "Journal entry was null");
            Assert.AreEqual(JournalStatus.Draft, j.Status, "Journal entry should have been in DRAFT status, but it was in " + j.Status.ToString() + " status.");
            Assert.AreEqual("PUBLIC", j.Class, "Journal class should have been PUBLIC, but was " + j.Class + ".");
            Assert.IsNull(j.Start);
        }
Exemple #10
0
        public void TestAlarm(string calendar, List <IDateTime> dates, iCalDateTime start, iCalDateTime end)
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars\Alarm\" + calendar)[0];

            ProgramTest.TestCal(iCal);
            IEvent evt = iCal.Events[0];

            // Poll all alarms that occurred between Start and End
            IList <AlarmOccurrence> alarms = evt.PollAlarms(start, end);

            foreach (AlarmOccurrence alarm in alarms)
            {
                Assert.IsTrue(dates.Contains(alarm.DateTime), "Alarm triggers at " + alarm.Period.StartTime + ", but it should not.");
            }
            Assert.IsTrue(dates.Count == alarms.Count, "There were " + alarms.Count + " alarm occurrences; there should have been " + dates.Count + ".");
        }
Exemple #11
0
        public void BASE64()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\BASE64.ics");

            ProgramTest.TestCal(iCal);
            Event evt = iCal.Events[0];

            Assert.IsTrue(evt.Attach[0].Value ==
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.\r\n" +
                          "This is a test to try out base64 encoding without being too large.", "Attached value does not match.");
        }
Exemple #12
0
        public void TestTodoCompleted(string calendar, ArrayList items)
        {
            var iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar)[0];

            ProgramTest.TestCal(iCal);
            var todo = iCal.Todos[0];

            for (var i = 0; i < items.Count; i += 2)
            {
                var dt = (IDateTime)items[i];
                dt.TzId = tzid;

                var tf = (bool)items[i + 1];
                if (tf)
                {
                    Assert.IsTrue(todo.IsCompleted(dt), "Todo should be completed at " + dt);
                }
                else
                {
                    Assert.IsFalse(todo.IsCompleted(dt), "Todo should not be completed at " + dt);
                }
            }
        }
Exemple #13
0
        public void ADDEVENT1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\GEO1.ics");

            ProgramTest.TestCal(iCal);

            Event evt = iCal.Create <Event>();

            evt.Summary     = "Test event";
            evt.Description = "This is an event to see if event creation works";
            evt.Start       = new iCalDateTime(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");
        }
Exemple #14
0
        public void TestTodoCompleted(string calendar, ArrayList items)
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Todo\" + calendar);

            ProgramTest.TestCal(iCal);
            DDay.iCal.Components.Todo todo = (DDay.iCal.Components.Todo)iCal.Todos[0];

            for (int i = 0; i < items.Count; i += 2)
            {
                iCalDateTime dt = (iCalDateTime)items[i];
                dt.iCalendar = iCal;
                dt.TZID      = tzid;

                bool tf = (bool)items[i + 1];
                if (tf)
                {
                    Assert.IsTrue(todo.IsCompleted(dt), "Todo should be completed at " + dt);
                }
                else
                {
                    Assert.IsFalse(todo.IsCompleted(dt), "Todo should not be completed at " + dt);
                }
            }
        }