Inheritance: ItemType
        public void MSOXWSCORE_S07_TC12_GetTaskItemWithAddBlankTargetToLinks()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2149908, this.Site), "Exchange 2007 and Exchange 2010 do not use the AddBlankTargetToLinks element.");

            TaskType item = new TaskType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_AddBlankTargetToLinksBoolean(item);
        }
        public void MSOXWSCORE_S07_TC13_GetTaskItemWithBlockExternalImages()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2149905, this.Site), "Exchange 2007 and Exchange 2010 do not use the BlockExternalImages element.");

            TaskType item = new TaskType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_BlockExternalImagesBoolean(item);
        }
        /// <summary>
        /// Define the task item via setting different kind of taskRecurrence value.
        /// </summary>
        /// <param name="subject">The subject of the task.</param>
        /// <param name="taskRecurrence">Recurrence element value of the task.</param>
        /// <returns>The task object.</returns>
        public static TaskType DefineTaskItem(string subject, TaskRecurrenceType taskRecurrence)
        {
            #region Define Task item

            TaskType taskItem = new TaskType
            {
                // The subject of a task.
                Subject = subject,

                // The actual amount of time that is spent on a task. 
                ActualWork = 5,
                ActualWorkSpecified = true,

                // The total amount of time that is associated with a task.
                TotalWork = 10,
                TotalWorkSpecified = true,

                // The billing information for a task.
                BillingInformation = "Discount: 10 dollars",

                // The collection of companies that are associated with a task.
                Companies = new string[] { "CompanyFirst", "CompanySecond" },

                // The collection of contacts that are associated with a task.
                Contacts = new string[] { "Alice", "Bob" },

                // The start date of a task. The start date cannot occur after due date.
                StartDate = DateTime.Parse("2011-8-4"),
                StartDateSpecified = true,

                // The due date of a task. The due date cannot occur before start date.
                DueDate = DateTime.Parse("2011-8-10"),
                DueDateSpecified = true,

                // The mileage for a task.
                Mileage = "15 km.",

                // The completion percentage of a task.
                PercentComplete = 50,
                PercentCompleteSpecified = true
            };

            // The recurrence of a task.
            if (taskRecurrence != null)
            {
                taskItem.Recurrence = taskRecurrence;
            }
            #endregion

            return taskItem;
        }
        public void MSOXWSCORE_S07_TC11_GetTaskItemWithConvertHtmlCodePageToUTF8()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(21498, this.Site), "Exchange 2007 and Exchange 2010 do not include the ConvertHtmlCodePageToUTF8 element.");

            TaskType item = new TaskType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_ConvertHtmlCodePageToUTF8Boolean(item);
        }
        public void MSOXWSCORE_S07_TC17_GetTaskItemWithIconIndexSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1917, this.Site), "Exchange 2007 and Exchange 2010 do not support the IconIndex element.");

            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            range.NumberOfOccurrences = 5;
            range.StartDate = System.DateTime.Now;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence = new TaskRecurrenceType();
            items[0].Recurrence.Item = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 createdTaskItemIds.GetLength(0),
                 "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            GetItemType getItem = new GetItemType();

            // Create item and return the item id.
            getItem.ItemIds = createdTaskItemIds;

            // Set the item shape's elements.
            getItem.ItemShape = new ItemResponseShapeType();
            getItem.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
            getItem.ItemShape.AdditionalProperties = new PathToUnindexedFieldType[] { new PathToUnindexedFieldType() { FieldURI = UnindexedFieldURIType.itemIconIndex } };

            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.COREAdapter.GetItem(getItem);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            #region Step 3: Assert the value of IconIndex element is "TaskRecur".
            TaskType[] taskItems = Common.GetItemsFromInfoResponse<TaskType>(getItemResponse);

            // One created item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 taskItems.GetLength(0),
                 "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 taskItems.GetLength(0));

            Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1917");
        
            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1917
            this.Site.CaptureRequirementIfAreEqual<IconIndexType>(
                IconIndexType.TaskRecur,
                taskItems[0].IconIndex,
                1917,
                @"[In Appendix C: Product Behavior] Implementation does support value ""TaskRecur"" of ""IconIndex"" simple type which specifies the recurring task icon. (Exchange 2013 and above follow this behavior.)");
            #endregion
        }
        public void MSOXWSCORE_S07_TC18_CreateTaskItemWithInvalidItemClass()
        {
            #region Step 1: Create the Task item with ItemClass set to IPM.Appointment.
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            TaskType item = new TaskType();
            createItemRequest.Items.Items = new ItemType[] { item };
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1);
            createItemRequest.Items.Items[0].ItemClass = "IPM.Appointment";
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorObjectTypeChanged,
                createItemResponse.ResponseMessages.Items[0].ResponseCode,
                "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Appointment.");
            #endregion

            #region Step 2: Create the Task item with ItemClass set to IPM.Contact.
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2);
            createItemRequest.Items.Items[0].ItemClass = "IPM.Contact";
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorObjectTypeChanged,
                createItemResponse.ResponseMessages.Items[0].ResponseCode,
                "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Contact.");
            #endregion

            #region Step 3: Create the Task item with ItemClass set to IPM.Post.
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 3);
            createItemRequest.Items.Items[0].ItemClass = "IPM.Post";
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorObjectTypeChanged,
                createItemResponse.ResponseMessages.Items[0].ResponseCode,
                "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.Task.");
            #endregion

            #region Step 4: Create the Task item with ItemClass set to IPM.DistList.
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 4);
            createItemRequest.Items.Items[0].ItemClass = "IPM.DistList";
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorObjectTypeChanged,
                createItemResponse.ResponseMessages.Items[0].ResponseCode,
                "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass IPM.DistList.");
            #endregion

            #region Step 5: Create the Task item with ItemClass set to random string.
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 5);
            createItemRequest.Items.Items[0].ItemClass = Common.GenerateResourceName(this.Site, "ItemClass");
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Site.Assert.AreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorObjectTypeChanged,
                createItemResponse.ResponseMessages.Items[0].ResponseCode,
                "ErrorObjectTypeChanged should be returned if create a Task item with ItemClass is set to a random string.");
            #endregion

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2023");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2023
            this.Site.CaptureRequirement(
                2023,
                @"[In t:ItemType Complex Type] If invalid values are set for these items in the CreateItem request, an ErrorObjectTypeChanged ([MS-OXWSCDATA] section 2.2.5.24) response code will be returned in the CreateItem response.");
        }
        public void MSOXWSCORE_S07_TC05_MarkAllTaskItemsAsReadSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1290, this.Site), "Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation.");

            TaskType[] items = new TaskType[] { new TaskType(), new TaskType() };
            this.TestSteps_VerifyMarkAllItemsAsRead(items);
        }
        public void MSOXWSCORE_S07_TC16_GetTaskItemWithTwoItemIdTypesSuccessfully()
        {
            #region Step 1: Create a recurring task item.
            // Define the pattern and range of the recurring task item.
            DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
            pattern.Interval = 1;

            NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
            int numberOfOccurrences = 5;
            range.NumberOfOccurrences = numberOfOccurrences;
            System.DateTime start = System.DateTime.Now;
            range.StartDate = start;

            // Define the TaskType item.
            TaskType[] items = new TaskType[] { new TaskType() };
            items[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            items[0].Recurrence = new TaskRecurrenceType();
            items[0].Recurrence.Item = pattern;
            items[0].Recurrence.Item1 = range;

            // Call CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            // Check the operation response.
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            BaseItemIdType[] createdTaskItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

            // One created task item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 createdTaskItemIds.GetLength(0),
                 "One created task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 createdTaskItemIds.GetLength(0));
            #endregion

            #region Step 2: Get the recurring task item by ItemIdType.
            // Call GetItem operation using the created task item ID.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdTaskItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
            #endregion

            // Exchange 2007 and Exchange 2010 do not support the RecurringMasterItemIdRanges element.
            SutVersion currentSutVersion = (SutVersion)Enum.Parse(typeof(SutVersion), Common.GetConfigurationPropertyValue("SutVersion", this.Site));
            if (currentSutVersion.Equals(SutVersion.ExchangeServer2013))
            {
                #region Step 3: Get the recurring task item by RecurringMasterItemIdRangesType.
                // Define the RecurringMasterItemIdRanges using the created task item ID.
                RecurringMasterItemIdRangesType[] recurringMasterItemIdRanges = new RecurringMasterItemIdRangesType[1];
                recurringMasterItemIdRanges[0] = new RecurringMasterItemIdRangesType();
                recurringMasterItemIdRanges[0].Id = (createdTaskItemIds[0] as ItemIdType).Id;
                recurringMasterItemIdRanges[0].ChangeKey = (createdTaskItemIds[0] as ItemIdType).ChangeKey;
                recurringMasterItemIdRanges[0].Ranges = new OccurrencesRangeType[1];
                recurringMasterItemIdRanges[0].Ranges[0] = new OccurrencesRangeType();
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTimeSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].CompareOriginalStartTime = true;
                recurringMasterItemIdRanges[0].Ranges[0].StartSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].Start = start;
                recurringMasterItemIdRanges[0].Ranges[0].EndSpecified = true;
                recurringMasterItemIdRanges[0].Ranges[0].End = start.AddDays(numberOfOccurrences);

                // Call GetItem operation using the recurringMasterItemIdRanges.
                getItemResponse = this.CallGetItemOperation(recurringMasterItemIdRanges);

                // Check the operation response.
                Common.CheckOperationSuccess(getItemResponse, 1, this.Site);
                #endregion
            }
        }
        public void MSOXWSCORE_S07_TC03_MoveTaskItemSuccessfully()
        {
            #region Step 1: Create the task item.
            TaskType item = new TaskType();
            ItemIdType[] createdItemIds = this.CreateItemWithMinimumElements(item);
            #endregion

            #region Step 2: Move the task item.
            // Clear ExistItemIds for MoveItem.
            this.InitializeCollection();

            // Call MoveItem operation.
            MoveItemResponseType moveItemResponse = this.CallMoveItemOperation(DistinguishedFolderIdNameType.inbox, createdItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(moveItemResponse, 1, this.Site);

            ItemIdType[] movedItemIds = Common.GetItemIdsFromInfoResponse(moveItemResponse);

            // One moved task item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 movedItemIds.GetLength(0),
                 "One moved task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 movedItemIds.GetLength(0));
            #endregion

            #region Step 3: Get the created task item failed.
            // Call the GetItem operation.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdItemIds);

            Site.Assert.AreEqual<int>(
                 1,
                 getItemResponse.ResponseMessages.Items.GetLength(0),
                 "Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemResponse.ResponseMessages.Items.GetLength(0));

            Site.Assert.AreEqual<ResponseClassType>(
                ResponseClassType.Error,
                getItemResponse.ResponseMessages.Items[0].ResponseClass,
                string.Format(
                    "Get task item operation should be failed with error! Actual response code: {0}",
                    getItemResponse.ResponseMessages.Items[0].ResponseCode));
            #endregion

            #region Step 4: Get the moved task item.
            // Call the GetItem operation.
            getItemResponse = this.CallGetItemOperation(movedItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

            ItemIdType[] getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

            // One task item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

            #endregion
        }
 public void MSOXWSCORE_S07_TC04_UpdateTaskItemSuccessfully()
 {
     TaskType item = new TaskType();
     this.TestSteps_VerifyUpdateItemSuccessfulResponse(item);
 }
        /// <summary>
        /// Verify the IntervalRecurrencePatternBaseType.
        /// </summary>
        /// <param name="sentTaskItem">The created task item.</param>
        /// <param name="retrievedTaskItemDaily">The retrieved task item.</param>
        private void VerifyIntervalRecurrencePatternBaseType(TaskType sentTaskItem, TaskType retrievedTaskItemDaily)
        {
            IntervalRecurrencePatternBaseType sentDailyRecur = sentTaskItem.Recurrence.Item as IntervalRecurrencePatternBaseType;
            IntervalRecurrencePatternBaseType retrievedDailyRecur = retrievedTaskItemDaily.Recurrence.Item as IntervalRecurrencePatternBaseType;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1179");

            // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R1179
            this.Site.CaptureRequirementIfAreEqual<int>(
                sentDailyRecur.Interval,
                retrievedDailyRecur.Interval,
                "MS-OXWSCDATA",
                1179,
                @"[In t:IntervalRecurrencePatternBaseType Complex Type] The element ""Interval"" with type ""xs:int"" specifies the interval between two consecutive recurring items.");
        }
        /// <summary>
        /// Create an item in the specified folder.
        /// </summary>
        /// <param name="parentFolderType">Type of the parent folder.</param>
        /// <param name="parentFolderId">ID of the parent folder.</param>
        /// <param name="itemSubject">Subject of the item which should be created.</param>
        /// <returns>ID of the created item.</returns>
        protected ItemIdType CreateItem(DistinguishedFolderIdNameType parentFolderType, string parentFolderId, string itemSubject)
        {
            // Create a request for the CreateItem operation and initialize the ItemType instance.
            CreateItemType createItemRequest = new CreateItemType();
            ItemType item = null;

            // Get different values for item based on different parent folder type.
            switch (parentFolderType)
            {
                case DistinguishedFolderIdNameType.contacts:
                    ContactItemType contact = new ContactItemType();
                    contact.Subject = itemSubject;
                    contact.FileAs = itemSubject;
                    item = contact;
                    break;
                case DistinguishedFolderIdNameType.calendar:
                    // Set the sendMeetingInvitations property.
                    CalendarItemCreateOrDeleteOperationType sendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone;
                    createItemRequest.SendMeetingInvitations = (CalendarItemCreateOrDeleteOperationType)sendMeetingInvitations;
                    createItemRequest.SendMeetingInvitationsSpecified = true;
                    CalendarItemType calendar = new CalendarItemType();
                    calendar.Subject = itemSubject;
                    item = calendar;
                    break;
                case DistinguishedFolderIdNameType.inbox:
                    MessageType message = new MessageType();
                    message.Subject = itemSubject;
                    item = message;
                    break;
                case DistinguishedFolderIdNameType.tasks:
                    TaskType taskItem = new TaskType();
                    taskItem.Subject = itemSubject;
                    item = taskItem;
                    break;
                default:
                    Site.Assert.Fail("The parent folder type '{0}' is invalid and the valid folder types are: contacts, calendar, inbox and tasks.", parentFolderType.ToString());
                    break;
            }

            // Set the MessageDisposition property.
            MessageDispositionType messageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.MessageDisposition = (MessageDispositionType)messageDisposition;
            createItemRequest.MessageDispositionSpecified = true;

            // Specify the folder in which new items are saved.
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();
            FolderIdType folderId = new FolderIdType();
            folderId.Id = parentFolderId;
            createItemRequest.SavedItemFolderId.Item = folderId;

            // Specify the collection of items to be created.
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { item };

            // Initialize the ID of the created item.
            ItemIdType createdItemId = null;

            // Invoke the create item operation and get the response.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);

            if (createItemResponse != null && createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                ItemInfoResponseMessageType info = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
                Site.Assert.IsNotNull(info, "The items in CreateItem response should not be null.");

                // Get the ID of the created item.
                createdItemId = info.Items.Items[0].ItemId;
            }

            return createdItemId;
        }
 /// <summary>
 /// Extract the start time of next occurrence for a DailyRecurrencePatternType task item.
 /// </summary>
 /// <param name="taskItem">The task item with daily recurrence pattern.</param>
 /// <returns>The start date time string of next occurrence.</returns>
 private static string ExtractStartTimeOfNextOccurrence(TaskType taskItem)
 {
     if (taskItem != null && taskItem.Recurrence != null && taskItem.Recurrence.Item != null && taskItem.Recurrence.Item1 != null)
     {
         DailyRecurrencePatternType dailyRecurrencePattern = taskItem.Recurrence.Item as DailyRecurrencePatternType;
         return taskItem.StartDate.AddDays(dailyRecurrencePattern.Interval).ToShortTimeString();
     }
     else
     {
         return null;
     }
 }
 public void MSOXWSCORE_S07_TC14_GetTaskItemWithDefaultShapeNamesTypeEnum()
 {
     TaskType item = new TaskType();
     this.TestSteps_VerifyGetItemWithItemResponseShapeType_DefaultShapeNamesTypeEnum(item);
 }
        public void MSOXWSCORE_S07_TC06_CreateTaskItemFailed()
        {
            #region Step 1: Create the task item with invalid item class.
            TaskType[] items = new TaskType[]
            { 
                new TaskType() 
                { 
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForCreateItem),

                    // Set an invalid ItemClass to post item.
                    ItemClass = TestSuiteHelper.InvalidItemClass
                }
            };

            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.tasks, items);

            #endregion

            // Get ResponseCode from CreateItem operation response.
            ResponseCodeType responseCode = createItemResponse.ResponseMessages.Items[0].ResponseCode;

            // Verify MS-OXWSCDATA_R619.
            this.VerifyErrorObjectTypeChanged(responseCode);
        }
 public void MSOXWSCORE_S07_TC15_GetTaskItemWithBodyTypeResponseTypeEnum()
 {
     TaskType item = new TaskType();
     this.TestSteps_VerifyGetItemWithItemResponseShapeType_BodyTypeResponseTypeEnum(item);
 }
 public void MSOXWSCORE_S07_TC07_UpdateTaskItemFailed()
 {
     TaskType item = new TaskType();
     this.TestSteps_VerifyUpdateItemFailedResponse(item);
 }
 public void MSOXWSCORE_S07_TC01_CreateGetDeleteTaskItemSuccessfully()
 {
     TaskType item = new TaskType();
     this.TestSteps_VerifyCreateGetDeleteItem(item);
 }
        public void MSOXWSCORE_S07_TC08_VerifyExtendPropertyType()
        {
            TaskType item = new TaskType();
            this.TestSteps_VerifyDistinguishedPropertySetIdConflictsWithPropertySetId(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyDistinguishedPropertySetIdConflictsWithPropertyTag(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyDistinguishedPropertySetIdWithPropertyTypeOrPropertyName(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertySetIdConflictsWithDistinguishedPropertySetId(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertySetIdConflictsWithPropertyTag(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertySetIdWithPropertyTypeOrPropertyName(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyTagRepresentation(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyTagConflictsWithDistinguishedPropertySetId(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyTagConflictsWithPropertyName(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyTagConflictsWithPropertyId(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyNameWithDistinguishedPropertySetIdOrPropertySetId(DistinguishedFolderIdNameType.tasks, item);

            this.TestSteps_VerifyPropertyIdWithDistinguishedPropertySetIdOrPropertySetId(DistinguishedFolderIdNameType.tasks, item);
        }
        public void MSOXWSCORE_S07_TC02_CopyTaskItemSuccessfully()
        {
            #region Step 1: Create the task item.
            TaskType item = new TaskType();
            ItemIdType[] createdItemIds = this.CreateItemWithMinimumElements(item);
            #endregion

            #region Step 2: Copy the task item.
            // Call CopyItem operation.
            CopyItemResponseType copyItemResponse = this.CallCopyItemOperation(DistinguishedFolderIdNameType.drafts, createdItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(copyItemResponse, 1, this.Site);

            ItemIdType[] copiedItemIds = Common.GetItemIdsFromInfoResponse(copyItemResponse);

            // One copied task item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 copiedItemIds.GetLength(0),
                 "One copied task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 copiedItemIds.GetLength(0));
            #endregion

            #region Step 3: Get the first created task item success.
            // Call the GetItem operation.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(createdItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

            ItemIdType[] getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

            // One task item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2021");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2021
            this.Site.CaptureRequirementIfAreEqual<string>(
                "IPM.Task",
                ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0].ItemClass,
                2021,
                @"[In t:ItemType Complex Type] This value is ""IPM.Task"" for task item.");
            #endregion

            #region Step 4: Get the second copied task item success.
            // Call the GetItem operation.
            getItemResponse = this.CallGetItemOperation(copiedItemIds);

            // Check the operation response.
            Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

            getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

            // One task item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One task item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));
            #endregion
        }
 public void MSOXWSCORE_S07_TC09_OperateMultipleTaskItemsSuccessfully()
 {
     TaskType[] items = new TaskType[] { new TaskType(), new TaskType() };
     this.TestSteps_VerifyOperateMultipleItems(items);
 }
        public void MSOXWSSYNC_S02_TC05_SyncFolderItems_TaskType()
        {
            #region Step 1. Client invokes SyncFolderItems operation to get initial syncState of tasks folder.
            DistinguishedFolderIdNameType taskFolder = DistinguishedFolderIdNameType.tasks;
            SyncFolderItemsType request = this.CreateSyncFolderItemsRequestWithoutOptionalElements(taskFolder, DefaultShapeNamesType.AllProperties);

            // Involve InlineImageUrlTemplate element in SyncFolderItems request
            if (Common.IsRequirementEnabled(37809, this.Site))
            {
                request.ItemShape.InlineImageUrlTemplate = "Test Template";
            }

            SyncFolderItemsResponseType response = this.SYNCAdapter.SyncFolderItems(request);
            SyncFolderItemsResponseMessageType responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderItemsResponseMessageType>(response);
            #endregion

            #region Step 2. Client invokes CreateItem to create a TaskType item and get its ID.
            TaskType taskItem = new TaskType();

            // Create two items on server to verify if the MaxSyncChangesReturned is set to 1, the last item should not be included in response
            BaseItemIdType[] firstItemId = this.CreateItem(taskFolder, taskItem);
            BaseItemIdType[] secondItemId = this.CreateItem(taskFolder, taskItem);
            #endregion

            #region Step 3. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 2 and verify related requirements.
            // Assert the SyncState is not null
            Site.Assert.IsNotNull(responseMessage.SyncState, "The synchronization should not be null.");
            request.SyncState = responseMessage.SyncState;

            // Set MaxSyncChangesReturned to a value that is less than the number of changes to be returned to verify the false value of "IncludesLastItemInRange" element
            request.MaxChangesReturned = 1;
            response = this.SYNCAdapter.SyncFolderItems(request);
            responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderItemsResponseMessageType>(response);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R6702");

            // There are two items created in step2, but the MaxSyncChangesReturned is set to 1, so the last item should not be included in response
            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R6702
            Site.CaptureRequirementIfIsFalse(
                responseMessage.IncludesLastItemInRange,
                6702,
                @"[In m:SyncFolderItemsResponseMessageType Complex Type] [The element IncludesLastItemInRange] False indicates the last item to synchronize is not included in the response.");

            // Assert the changes in response is not null
            Site.Assert.IsNotNull(responseMessage.Changes, "There is one item created on server, so the changes between server and client should not be null");
            SyncFolderItemsChangesType changes = responseMessage.Changes;

            // Assert both the Items and ItemsElementName are not null
            Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderItems response since there is one item created on server.");
            Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item created on server.");

            Site.Assert.AreEqual<int>(
                1,
                changes.Items.Length,
                "There are two TaskType items were created in previous step, but if the MaxChangesReturned is set to 1, the count of Items array in responseMessage.Changes should be 1.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R3891");

            // There are two items created on server, but if the value of MaxChangesRetured is set to 1, there should be just one item returned in changes
            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R3891
            Site.CaptureRequirement(
                3891,
                @"[In m:SyncFolderItemsType Complex Type] This element [MaxChangesReturned] is set between 1 and 512, inclusive, the correct changes number returned in a synchronization response.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R388");

            // If the description of MS-OXWSSYNC_R3891 is true, then requirement MS-OXWSSYNC_R388 can be captured.
            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R388
            Site.CaptureRequirement(
                388,
                @"[In m:SyncFolderItemsType Complex Type] [The element MaxChangesReturned] specifies the maximum number of changes that can be returned in a synchronization response.");

            // If the type of item in SyncFolderItems response is TaskType, then requirement MS-OXWSSYNC_R172 can be captured.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R172");

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R172
            Site.CaptureRequirementIfIsInstanceOfType(
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item,
                typeof(TaskType),
                172,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type]The type of Task is t:TaskType ([MS-OXWSTASK] section 2.2.4.6).");

            Site.Assert.AreEqual<int>(
                1,
                changes.ItemsElementName.Length,
                "There are two TaskType items were created in previous step, but if the MaxChangesReturned is set to 1, the count of ItemsElementName array in responseMessage.Changes should be 1.");

            bool isTaskTypeItemCreated = changes.ItemsElementName[0] == ItemsChoiceType1.Create &&
                    (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(TaskType);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R1731. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}",
                ItemsChoiceType1.Create,
                typeof(TaskType),
                changes.ItemsElementName[0],
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType());

            // If the ItemsElementName of Changes is Create and the type of Item is TaskType, it indicates a task 
            // has been created on server and synced on client, then requirement MS-OXWSSYNC_R1731 can be captured.
            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1731
            Site.CaptureRequirementIfIsTrue(
                isTaskTypeItemCreated,
                1731,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type][The element Task] specifies a task to create in the client message store.");

            // If MS-OXWSSYNC_R37809 is enabled, then verify this requirement
            if (Common.IsRequirementEnabled(37809, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R37809");

                // If the request involves the InlineImageUrlTemplate element and response is successful, then requirement MS-OXWSSYNC_37809 can be captured.
                // Verify MS-OXWSSYNC: MS-OXWSSYNC_R37809
                Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                    ResponseClassType.Success,
                    responseMessage.ResponseClass,
                    37809,
                    @"[In Appendix C: Product Behavior] Implementation does use the InlineImageUrlTemplate element. The InlineImageUrlTemplate element which is subelement 
                of ItemShape specifies the name of the template for the inline image URL. (Exchange 2013 and above follow this behavior.)");
            }
            #endregion

            #region Step 4. Client invokes DeleteItem operation to delete the second item that created in step2.
            this.DeleteItem(secondItemId);
            #endregion

            #region Step 5. Client invokes SyncFolderItems operation with previous SyncState to get the SyncState
            responseMessage = this.GetResponseMessage(taskFolder, responseMessage, DefaultShapeNamesType.AllProperties);
            #endregion

            #region Step 6. Client invokes UpdateItem operation to update the created item which created in Step 2.
            // Generate a new item subject
            string newItemSubject = Common.GenerateResourceName(this.Site, taskFolder + "NewItemSubject");
            this.UpdateItemSubject(firstItemId, newItemSubject);
            #endregion

            #region Step 7. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 6 and verify related requirements.
            responseMessage = this.GetResponseMessage(taskFolder, responseMessage, DefaultShapeNamesType.AllProperties);

            // Assert the changes in response is not null
            Site.Assert.IsNotNull(responseMessage.Changes, "There is one item updated on server, so the changes between server and client should not be null");
            changes = responseMessage.Changes;

            // Assert both the Items and ItemsElementName are not null
            Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderItems response since there is one item updated on server.");
            Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item updated on server.");

            Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one TaskType item was updated in previous step, so the count of Items array in responseMessage.Changes should be 1.");
            Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one TaskType item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");

            bool isTaskItemUpdated = changes.ItemsElementName[0] == ItemsChoiceType1.Update
                && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(TaskType);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R1732. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}",
                ItemsChoiceType1.Update,
                typeof(TaskType),
                changes.ItemsElementName[0],
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType());

            // If the ItemsElementName of Changes is Update and the type of Item is TaskType, it indicates a task
            // has been updated on server and synced on client, then requirement MS-OXWSSYNC_R1732 can be captured.
            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1732
            Site.CaptureRequirementIfIsTrue(
                isTaskItemUpdated,
                1732,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type][The element Task] specifies a task to update in the client message store.");
            #endregion

            #region Step 8. Client invokes DeleteItem operation to delete the TaskType item which updated in Step 6.
            this.DeleteItem(firstItemId);
            #endregion

            #region Step 9. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 8.
            responseMessage = this.GetResponseMessage(taskFolder, responseMessage, DefaultShapeNamesType.AllProperties);

            // Assert the changes in response is not null
            Site.Assert.IsNotNull(responseMessage.Changes, "There is one item deleted on server, so the changes between server and client should not be null");
            changes = responseMessage.Changes;

            // Assert both the Items and ItemsElementName are not null
            Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderItems response since there is one item deleted on server.");
            Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item deleted on server.");

            Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one TaskType item was deleted in previous step, so the count of Items array in responseMessage.Changes should be 1.");
            Site.Assert.IsTrue(
                changes.Items[0].GetType() == typeof(SyncFolderItemsDeleteType),
                string.Format("The responseMessage.Changes.Items should be an instance of '{0}'.", typeof(SyncFolderItemsDeleteType)));

            Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one TaskType item was deleted in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");
            Site.Assert.IsTrue(
                changes.ItemsElementName[0] == ItemsChoiceType1.Delete,
                string.Format("The responseMessage.Changes.ItemsElementName should be 'Delete', the actual value is '{0}'", changes.ItemsElementName[0]));
            #endregion
        }
        /// <summary>
        /// Generate UpdateItemRequest.
        /// </summary>
        /// <param name="createItemIds">The created item id.</param>
        /// <returns>Generated GetItemRequest.</returns>
        public static UpdateItemType GenerateUpdateItemRequest(params ItemIdType[] createItemIds)
        {
            // Specify needed to update value for the task item.
            TaskType taskUpdate = new TaskType
            {
                Companies = new string[] { "Company3", "Company4" }
            };

            // Define the ItemChangeType element for updating the task item's companies.
            PathToUnindexedFieldType pathTo = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.taskCompanies
            };

            SetItemFieldType setItemField = new SetItemFieldType()
            {
                Item = pathTo,
                Item1 = taskUpdate
            };

            ItemChangeType[] itemChanges = new ItemChangeType[createItemIds.Length];
            for (int i = 0; i < createItemIds.Length; i++)
            {
                ItemChangeType itemChange = new ItemChangeType()
                {
                    Item = createItemIds[i],
                    Updates = new ItemChangeDescriptionType[] { setItemField }
                };
                itemChanges[i] = itemChange;
            }

            // Return the UpdateItemType request to update the task item.
            return new UpdateItemType()
            {
                ItemChanges = itemChanges,
                ConflictResolution = ConflictResolutionType.AlwaysOverwrite
            };
        }