public void TestReplaceTaskICal() { Application app = new ApplicationClass(); OutlookTasksWithICal agent = new OutlookTasksWithICal(app); OutlookTasks outlookAgent = new OutlookTasks(app); TestAddTaskICal(); string existingEntryId = outlookAgent.GetEntryIdByDisplayName("Demo Task Sunbird"); string x = File.ReadAllText(MockPath + "todo.ics"); string entryId = agent.ReplaceItem(x, existingEntryId); Assert.IsTrue(entryId == existingEntryId); TaskItem task = outlookAgent.GetItemByEntryId(entryId); var collection = iCalendar.LoadFromFile(MockPath + "todo.ics"); var calendar = collection.FirstOrDefault(); var todo = calendar.Todos[0]; CompareIcalTodoAndAppointment(todo, task); System.Threading.Thread.Sleep(5000);//Silly, outlook will take a few seconds to finish the creation of the task object. Without such waiting, readind the item may be incorrect. //Test ReadItemToText() string icalText = agent.ReadItemToText(task); collection = iCalendar.LoadFromStream(new StringReader(icalText)); calendar = collection.FirstOrDefault(); todo = calendar.Todos[0]; CompareIcalTodoAndAppointment(todo, task); }
public void TestAddTaskICal() { string x = File.ReadAllText(MockPath + "todo.ics"); Application app = new ApplicationClass(); OutlookTasksWithICal agent = new OutlookTasksWithICal(app); OutlookTasks outlookAgent = new OutlookTasks(app); string entryId = outlookAgent.GetEntryIdByDisplayName("Demo Task Sunbird"); if (entryId != null) { bool deletionOK = outlookAgent.DeleteItem(entryId); Assert.IsTrue(deletionOK); } agent.AddItem(x); //also test ReadTextToItem() entryId = outlookAgent.GetEntryIdByDisplayName("Demo Task Sunbird"); Assert.IsTrue(entryId != null); TaskItem task = outlookAgent.GetItemByEntryId(entryId); var collection = iCalendar.LoadFromFile(MockPath + "todo.ics"); var calendar = collection.FirstOrDefault(); var todo = calendar.Todos[0]; CompareIcalTodoAndAppointment(todo, task); }