예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
            }
        }