Пример #1
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);
            }
        }
Пример #2
0
        string AddCalendar()
        {
            XElement                x            = XElement.Load(MockPath + "SifE.xml");
            Application             app          = new Application();
            OutlookCalendarWithSifE agent        = new OutlookCalendarWithSifE(app);
            OutlookCalendar         outlookAgent = new OutlookCalendar(app, CalendarPeriod.All);

            string entryId = outlookAgent.GetEntryIdByDisplayName(subject);

            if (entryId != null)
            {
                bool deletionOK = outlookAgent.DeleteItem(entryId);
                Assert.IsTrue(deletionOK);
            }
            agent.AddItem(x.ToString());
            entryId = outlookAgent.GetEntryIdByDisplayName(subject);
            Assert.IsTrue(entryId != null);
            return(entryId);
        }