Beispiel #1
0
        public void TestRRuleUntilSerialization()
        {
            var rrule = new RecurrencePattern(FrequencyType.Daily)
            {
                Until = _nowTime.AddDays(7),
            };
            const string someTz = "Europe/Volgograd";
            var          e      = new CalendarEvent
            {
                Start           = new CalDateTime(_nowTime, someTz),
                End             = new CalDateTime(_nowTime.AddHours(1), someTz),
                RecurrenceRules = new List <RecurrencePattern> {
                    rrule
                },
            };
            var c = new Calendar
            {
                Events = { e },
            };
            var serialized = new CalendarSerializer().SerializeToString(c);
            var serializedUntilNotContainsZSuffix = serialized
                                                    .Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
                                                    .Single(line => line.StartsWith("RRULE:", StringComparison.Ordinal));
            var untilIndex = serializedUntilNotContainsZSuffix.IndexOf("UNTIL", StringComparison.Ordinal);
            var until      = serializedUntilNotContainsZSuffix.Substring(untilIndex);

            Assert.IsTrue(!until.EndsWith("Z"));
        }
        public void AddPropertyShouldNotIncludePropertyNameInValue()
        {
            const string propName  = "X-WR-CALNAME";
            const string propValue = "Testname";

            var iCal = new Calendar();

            iCal.AddProperty(propName, propValue);

            var result = new CalendarSerializer().SerializeToString(iCal);

            var lines    = result.Split(new [] { SerializationConstants.LineBreak }, StringSplitOptions.None);
            var propLine = lines.FirstOrDefault(x => x.StartsWith("X-WR-CALNAME:"));

            Assert.AreEqual($"{propName}:{propValue}", propLine);
        }