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); }
/// <summary> /// /// </summary> /// <param name="taskIDs"></param> /// <returns></returns> public OutlookTasks LoadTasksByID(IEnumerable <string> taskIDs) { var tasks = new OutlookTasks(); var hierarchy = GetTaskHierarchy(); if (hierarchy.Any()) { tasks.AddRange(Flatten(hierarchy).Where(t => taskIDs.Contains(t.OneNoteTaskID))); } return(tasks); }
public void TestReplaceTasks() { Application app = new ApplicationClass(); OutlookTasksWithSifT agent = new OutlookTasksWithSifT(app); OutlookTasks outlookAgent = new OutlookTasks(app); TestAddTasks(); string existingEntryId = outlookAgent.GetEntryIdByDisplayName(subject); XElement x = XElement.Load(MockPath + "SifT.xml"); string entryId = agent.ReplaceItem(x.ToString(), existingEntryId); Assert.AreEqual(entryId, existingEntryId); //Compare added item with SIFT.xml TaskItem task = outlookAgent.GetItemByEntryId(entryId); Assert.AreEqual(task.Body, x.Element("Body").Value); Assert.AreEqual(task.Categories, x.Element("Categories").Value); Assert.AreEqual(task.Companies, x.Element("Companies").Value); Assert.AreEqual(((int)task.Importance).ToString(), x.Element("Importance").Value); Assert.AreEqual(task.Complete, x.Element("Complete").Value == "0" ? false : true); Assert.AreEqual(DataUtility.DateTimeToIsoText(task.DueDate), x.Element("DueDate").Value); Assert.AreEqual(task.BillingInformation, x.Element("BillingInformation").Value); Assert.AreEqual(task.ActualWork.ToString(), x.Element("ActualWork").Value); Assert.AreEqual(task.IsRecurring, x.Element("IsRecurring").Value == "0" ? false : true); Assert.AreEqual(task.Mileage, x.Element("Mileage").Value); Assert.AreEqual(task.PercentComplete.ToString(), x.Element("PercentComplete").Value); Assert.AreEqual(task.ReminderSet, x.Element("ReminderSet").Value == "0" ? false : true); Assert.AreEqual(DataUtility.DateTimeToIsoText(task.ReminderTime.ToUniversalTime()), x.Element("ReminderTime").Value); Assert.AreEqual(((int)task.Sensitivity).ToString(), x.Element("Sensitivity").Value); // Assert.AreEqual(DataUtility.DateTimeToISOText(task.StartDate), x.Element("StartDate").Value); StartDate may be altered by PatternStartDate and RecurrencePattern Assert.AreEqual(((int)task.Status).ToString(), x.Element("Status").Value); Assert.AreEqual(task.Subject, x.Element("Subject").Value); Assert.AreEqual(task.TeamTask, x.Element("TeamTask").Value == "0" ? false : true); Assert.AreEqual(task.TotalWork.ToString(), x.Element("TotalWork").Value); if (task.IsRecurring) { Microsoft.Office.Interop.Outlook.RecurrencePattern pattern = task.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 } }
public void TestAddTasks() { XElement x = XElement.Load(MockPath + "SifT.xml"); Application app = new ApplicationClass(); OutlookTasksWithSifT agent = new OutlookTasksWithSifT(app); OutlookTasks outlookAgent = new OutlookTasks(app); 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); }
/// <summary> /// Initialize a new instance of this folder /// </summary> public OutlookTaskFolder() { Folders = new OutlookTaskFolders(); Tasks = new OutlookTasks(); }