Example #1
0
        public void TestReplaceCalendarICal()
        {
            Application             app          = new Application();
            OutlookCalendarWithICal agent        = new OutlookCalendarWithICal(app);
            OutlookCalendar         outlookAgent = new OutlookCalendar(app, CalendarPeriod.All);
            //   TestAddCalendarICal();
            string existingEntryId = outlookAgent.GetEntryIdByDisplayName(iCalSubject);

            string x       = File.ReadAllText(MockPath + "Outlook demo event.ics");
            string entryId = agent.ReplaceItem(x, existingEntryId);

            Assert.IsTrue(entryId == existingEntryId);

            AppointmentItem appointment = outlookAgent.GetItemByEntryId(entryId);

            var calendarCollection = iCalendar.LoadFromFile(MockPath + "Outlook demo event.ics");
            var calendar           = calendarCollection.FirstOrDefault();
            var icalEvent          = calendar.Events[0];

            CompareIcalEventAndAppointment(icalEvent, appointment);

            //Test ReadItemToText()
            string icalText = agent.ReadItemToText(appointment);

            calendarCollection = iCalendar.LoadFromStream(new StringReader(icalText));
            calendar           = calendarCollection.FirstOrDefault();
            icalEvent          = calendar.Events[0];
            CompareIcalEventAndAppointment(icalEvent, appointment);
        }
Example #2
0
        public void TestAddCalendarICal()
        {
            string                  x            = File.ReadAllText(MockPath + "Outlook demo event.ics");
            Application             app          = new Application();
            OutlookCalendarWithICal agent        = new OutlookCalendarWithICal(app);
            OutlookCalendar         outlookAgent = new OutlookCalendar(app, CalendarPeriod.All);

            string entryId = outlookAgent.GetEntryIdByDisplayName(iCalSubject);

            if (entryId != null)
            {
                bool deletionOK = outlookAgent.DeleteItem(entryId);
                Assert.IsTrue(deletionOK);
            }
            agent.AddItem(x); //also test ReadTextToItem()
            entryId = outlookAgent.GetEntryIdByDisplayName(iCalSubject);
            Assert.IsTrue(entryId != null);

            AppointmentItem appointment = outlookAgent.GetItemByEntryId(entryId);

            var calendarCollection = iCalendar.LoadFromFile(MockPath + "Outlook demo event.ics");
            var calendar           = calendarCollection.FirstOrDefault();
            var icalEvent          = calendar.Events[0];

            CompareIcalEventAndAppointment(icalEvent, appointment);
        }
Example #3
0
        public void TestReplaceCalendar()
        {
            Application             app          = new Application();
            OutlookCalendarWithSifE agent        = new OutlookCalendarWithSifE(app);
            OutlookCalendar         outlookAgent = new OutlookCalendar(app, CalendarPeriod.All);


            string existingEntryId = AddCalendar();

            XElement x       = XElement.Load(MockPath + "SifE.xml");
            string   entryId = agent.ReplaceItem(x.ToString(), existingEntryId);

            Assert.IsTrue(entryId == existingEntryId);

            AppointmentItem appointment = outlookAgent.GetItemByEntryId(entryId);

            Assert.AreEqual(appointment.Subject, x.Element("Subject").Value);
            Assert.AreEqual(((int)appointment.BusyStatus).ToString(), x.Element("BusyStatus").Value);
            Assert.AreEqual(appointment.Categories, x.Element("Categories").Value);
            Assert.AreEqual(appointment.Companies, x.Element("Companies").Value);
            Assert.AreEqual(((int)appointment.Importance).ToString(), x.Element("Importance").Value);
            Assert.AreEqual(appointment.AllDayEvent, x.Element("AllDayEvent").Value == "0"?false:true);
            //   Assert.AreEqual(appointment.IsRecurring, x.Element("IsRecurring").Value=="0"?false:true);no need to check recurring events in sync.
            Assert.AreEqual(appointment.Location, x.Element("Location").Value);
            Assert.AreEqual(((int)appointment.MeetingStatus).ToString(), x.Element("MeetingStatus").Value);
            Assert.AreEqual(appointment.Mileage, x.Element("Mileage").Value);
            Assert.AreEqual(appointment.ReminderMinutesBeforeStart.ToString(), x.Element("ReminderMinutesBeforeStart").Value);
            Assert.AreEqual(appointment.ReminderSet, x.Element("ReminderSet").Value == "0"?false:true);
            Assert.AreEqual(appointment.ReminderSoundFile, x.Element("ReminderSoundFile").Value);
            Assert.AreEqual(DataUtility.DateTimeToIsoText(appointment.ReplyTime.ToUniversalTime()), x.Element("ReplyTime").Value);
            //     Assert.AreEqual(((int)appointment.Sensitivity).ToString(), x.Element("Sensitivity").Value);

            if (appointment.IsRecurring)
            {
                Microsoft.Office.Interop.Outlook.RecurrencePattern pattern = appointment.GetRecurrencePattern();
                Assert.AreEqual(pattern.Interval.ToString(), x.Element("Interval").Value);
                Assert.AreEqual(pattern.MonthOfYear.ToString(), x.Element("MonthOfYear").Value);
                Assert.AreEqual(pattern.DayOfMonth.ToString(), x.Element("DayOfMonth").Value);
                Assert.AreEqual(((int)pattern.DayOfWeekMask).ToString(), x.Element("DayOfWeekMask").Value);
                Assert.AreEqual(pattern.Instance.ToString(), x.Element("Instance").Value);
                Assert.AreEqual(DataUtility.DateTimeToIsoText(pattern.PatternStartDate), x.Element("PatternStartDate").Value);
                Assert.AreEqual(DataUtility.DateTimeToIsoText(pattern.PatternEndDate), x.Element("PatternEndDate").Value);
                Assert.AreEqual(pattern.NoEndDate, x.Element("NoEndDate").Value == "0" ? false : true);
                //     Assert.AreEqual(pattern.Occurrences.ToString(), x.Element("Occurrences").Value); no need to test
            }
            else
            {
                Assert.AreEqual(appointment.Start.ToUniversalTime().ToString("yyyyMMddTHHmmssZ"), x.Element("Start").Value);
                Assert.AreEqual(appointment.End.ToUniversalTime().ToString("yyyyMMddTHHmmssZ"), x.Element("End").Value);
            }
        }