示例#1
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
            }
        }
示例#2
0
        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);
        }