Beispiel #1
0
        public void Categories1_2()
        {
            var iCal = SimpleDeserializer.Default.Deserialize(new StringReader(IcsFiles.Categories1)).Cast <Calendar>().Single();

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            var items = new List <string>();

            items.AddRange(new[]
            {
                "One", "Two", "Three",
                "Four", "Five", "Six",
                "Seven", "A string of text with nothing less than a comma, semicolon; and a newline\n."
            });

            var found = new Dictionary <string, bool>();

            foreach (var s in evt.Categories.Where(s => items.Contains(s)))
            {
                found[s] = true;
            }

            foreach (string item in items)
            {
                Assert.IsTrue(found.ContainsKey(item), "Event should contain CATEGORY '" + item + "', but it was not found.");
            }
        }
Beispiel #2
0
        public void GeographicLocation1_2()
        {
            var iCal = Calendar.LoadFromStream(new StringReader(IcsFiles.GeographicLocation1))[0];

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual(37.386013, evt.GeographicLocation.Latitude, "Latitude should be 37.386013; it is not.");
            Assert.AreEqual(-122.082932, evt.GeographicLocation.Longitude, "Longitude should be -122.082932; it is not.");
        }
Beispiel #3
0
        public void Encoding3()
        {
            var iCal = Calendar.LoadFromStream(new StringReader(IcsFiles.Encoding3))[0];

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual("uuid1153170430406", evt.Uid, "UID should be 'uuid1153170430406'; it is " + evt.Uid);
            Assert.AreEqual(1, evt.Sequence, "SEQUENCE should be 1; it is " + evt.Sequence);
        }
Beispiel #4
0
        public void GeographicLocation1_2()
        {
            var iCal = SimpleDeserializer.Default.Deserialize(new StringReader(IcsFiles.GeographicLocation1)).Cast <ICalendar>().Single();

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual(37.386013, evt.GeographicLocation.Latitude, "Latitude should be 37.386013; it is not.");
            Assert.AreEqual(-122.082932, evt.GeographicLocation.Longitude, "Longitude should be -122.082932; it is not.");
        }
Beispiel #5
0
        public void Encoding3()
        {
            var iCal = SimpleDeserializer.Default.Deserialize(new StringReader(IcsFiles.Encoding3)).Cast <ICalendar>().Single();

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual("uuid1153170430406", evt.Uid, "UID should be 'uuid1153170430406'; it is " + evt.Uid);
            Assert.AreEqual(1, evt.Sequence, "SEQUENCE should be 1; it is " + evt.Sequence);
        }
Beispiel #6
0
        public void Journal1()
        {
            var iCal = Calendar.LoadFromStream(new StringReader(IcsFiles.JOURNAL1))[0];

            ProgramTest.TestCal(iCal);
            Assert.AreEqual(1, iCal.Journals.Count);
            var 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 + " status.");
            Assert.AreEqual("PUBLIC", j.Class, "Journal class should have been PUBLIC, but was " + j.Class + ".");
            Assert.IsNull(j.Start);
        }
Beispiel #7
0
        public void CompletedTodo_Tests(string calendarString, IList <KeyValuePair <CalDateTime, bool> > incoming)
        {
            var iCal = Calendar.LoadFromStream(new StringReader(calendarString))[0];

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

            foreach (var calDateTime in incoming)
            {
                var dt = calDateTime.Key;
                dt.TzId = _tzid;
                Assert.AreEqual(calDateTime.Value, todo.IsCompleted(dt));
            }
        }
Beispiel #8
0
        public void TestAlarm(string calendarString, List <IDateTime> dates, CalDateTime start, CalDateTime end)
        {
            var iCal = Calendar.LoadFromStream(new StringReader(calendarString))[0];

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

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

            foreach (var 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 + ".");
        }
Beispiel #9
0
        public void TestAlarm(string calendarString, List <IDateTime> dates, CalDateTime start, CalDateTime end)
        {
            var iCal = Calendar.LoadFromStream(new StringReader(calendarString))[0];

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

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

            //Only compare the UTC values here, since we care about the time coordinate when the alarm fires, and nothing else
            foreach (var alarm in alarms.Select(a => a.DateTime.AsUtc))
            {
                Assert.IsTrue(dates.Select(d => d.AsUtc).Contains(alarm), "Alarm triggers at " + alarm + ", but it should not.");
            }
            Assert.IsTrue(dates.Count == alarms.Count, "There were " + alarms.Count + " alarm occurrences; there should have been " + dates.Count + ".");
        }
Beispiel #10
0
        public void Encoding2()
        {
            var iCal = Calendar.LoadFromStream(new StringReader(IcsFiles.Encoding2))[0];

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual(
                "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.",
                evt.Attachments[0].ToString(),
                "Attached value does not match.");
        }
Beispiel #11
0
        public void Encoding2()
        {
            var iCal = SimpleDeserializer.Default.Deserialize(new StringReader(IcsFiles.Encoding2)).Cast <ICalendar>().Single();

            ProgramTest.TestCal(iCal);
            var evt = iCal.Events.First();

            Assert.AreEqual(
                "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.",
                evt.Attachments[0].ToString(),
                "Attached value does not match.");
        }