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); }
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); }
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); }