Inheritance: ItemType
        public void MSOXWSCORE_S04_TC20_VerifyOperationsWithSOAPHeaderSuccessful()
        {
            #region Step 1: Create one item with recipient.
            // Clear the soap header.
            this.ClearSoapHeaders();

            // Configure the SOAP headers for CreateItem and UpdateItem operations.
            Dictionary<string, object> headerValues = new Dictionary<string, object>();
            headerValues = this.ConfigureSOAPHeader();

            // Configure the TimeZoneContext SOAP Header.
            TimeZoneContextType timeZoneContext = new TimeZoneContextType();
            timeZoneContext.TimeZoneDefinition = new TimeZoneDefinitionType();
            timeZoneContext.TimeZoneDefinition.Id = TestSuiteHelper.TimeZoneID;

            headerValues.Add("TimeZoneContext", timeZoneContext);
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the CreateItem operation and save the item to Drafts folder.
            MessageType[] items = new MessageType[] { this.CreateItemWithOneRecipient() };

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

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

            MessageType[] createdItems = Common.GetItemsFromInfoResponse<MessageType>(createItemResponse);

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

            #region Step 2: Update the item which is created in Step 1.
            ItemChangeType[] itemChanges = new ItemChangeType[]
            {
                TestSuiteHelper.CreateItemChangeItem(createdItems[0], 1)
            };

            // Clear ExistItemIds list for MoveItem.
            this.InitializeCollection();

            // Call UpdateItem operation to update the subject of the created item, by using the ItemId in CreateItem response.
            UpdateItemResponseType updateItemResponse = this.CallUpdateItemOperation(
                DistinguishedFolderIdNameType.drafts,
                true,
                itemChanges);

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

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 3: Move the item updated in Step 2 from Drafts folder to Inbox folder.
            // Configure the SOAP headers for MoveItem and MarkAllItemsAsRead operations.
            headerValues.Remove("TimeZoneContext");
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the MoveItem operation, by using the ItemId in UpdateItem response.
            ItemIdType[] draftsItem = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(draftsItem, 0);
            this.InitializeCollection();
            MoveItemResponseType moveItemResponse = this.CallMoveItemOperation(DistinguishedFolderIdNameType.inbox, draftsItem);

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

            #region Step 4: Mark all items in Inbox folder as read.
            // Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation.
            if (Common.IsRequirementEnabled(1290, this.Site))
            {
                // Configure Inbox folder as the target folder.
                BaseFolderIdType[] folderIds = new BaseFolderIdType[1];
                DistinguishedFolderIdType distinguishedFolder = new DistinguishedFolderIdType();
                distinguishedFolder.Id = DistinguishedFolderIdNameType.inbox;
                folderIds[0] = distinguishedFolder;

                // Mark all items in Inbox folder as unread, and suppress the receive receipts.
                MarkAllItemsAsReadResponseType markAllItemsAsReadResponse = this.CallMarkAllItemsAsReadOperation(true, true, folderIds);

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

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

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1290
                // The MarkAllItemsAsRead operation was executed successfully, so this requirement can be captured.
                this.Site.CaptureRequirementIfIsTrue(
                    this.IsSchemaValidated,
                    1290,
                    @"[In Appendix C: Product Behavior] Implementation does support the MarkAllItemsAsRead operation which marks all items in a folder as read. (Exchange 2013  and above follow this behavior.)");
            }

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 5: Get the item in Inbox folder.
            // Configure the SOAP headers for GetItem.
            headerValues.Add("TimeZoneContext", timeZoneContext);
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Call the GetItem operation, by using the ItemId in MoveItem response.
            ItemIdType[] itemArray = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(itemArray, 0);
            GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray);

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

            // Clear the soap header.
            this.ClearSoapHeaders();
            #endregion

            #region Step 6: Copy the message type item from Inbox folder to Drafts folder.
            // Configure the SOAP headers for CopyItem, SendItem and DeleteItem.
            headerValues.Remove("TimeZoneContext");
            this.COREAdapter.ConfigureSOAPHeader(headerValues);

            // Save the ID of the item in Inbox folder and call the CopyItem operation.
            itemArray = new ItemIdType[this.ExistItemIds.Count];
            this.ExistItemIds.CopyTo(itemArray, 0);
            CopyItemResponseType copyItemResponse = this.CallCopyItemOperation(DistinguishedFolderIdNameType.drafts, itemArray);

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

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

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

            #region Step 7: Send the item in Drafts folder.
            // Call SendItem to send the copied item in Drafts folder, by using copiedItemIds in CopyItem response.
            SendItemResponseType sendResponse = this.CallSendItemOperation(
                copiedItemIds,
                DistinguishedFolderIdNameType.sentitems,
                false);

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

            // Remove the sent itemId from ExistItemIds list, since the item has been sent out and no copy remains.
            this.ExistItemIds.Remove(copiedItemIds[0] as ItemIdType);
            #endregion

            #region Step 8: Delete the item in Inbox folder and clean all items sent out.
            // Delete the item in Inbox folder and clear the ExistItemIds list.
            DeleteItemResponseType deleteItemResponse = this.CallDeleteItemOperation();

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

            this.InitializeCollection();

            // Clear the soap header.
            this.ClearSoapHeaders();

            // Clean the items sent out.
            this.CleanItemsSentOut(new string[] { items[0].Subject });
            #endregion
        }
 public void MSOXWSCORE_S04_TC11_GetEmailItemWithIncludeMimeContent()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyGetItemWithItemResponseShapeType_IncludeMimeContentBoolean(item);
 }
        /// <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>
        /// Create item within a specific folder.
        /// </summary>
        /// <param name="toAddress">To address of created item</param>
        /// <param name="folderId">Parent folder id of the created item.</param>
        /// <param name="subject">Subject of the item.</param>
        /// <returns>Id of created item.</returns>
        protected ItemIdType CreateItem(string toAddress, string folderId, string subject)
        {
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.MessageDispositionSpecified = true;
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();

            DistinguishedFolderIdType distinguishedFolderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType distinguishedFolderIdName = new DistinguishedFolderIdNameType();
            bool isSuccess = Enum.TryParse<DistinguishedFolderIdNameType>(folderId, true, out distinguishedFolderIdName);

            if (isSuccess)
            {
                distinguishedFolderId.Id = distinguishedFolderIdName;
                createItemRequest.SavedItemFolderId.Item = distinguishedFolderId;
            }
            else
            {
                FolderIdType id = new FolderIdType();
                id.Id = folderId;
                createItemRequest.SavedItemFolderId.Item = id;
            }

            MessageType message = new MessageType();
            message.Subject = subject;
            EmailAddressType address = new EmailAddressType();
            address.EmailAddress = toAddress;

            // Set this message to unread.
            message.IsRead = false;
            message.IsReadSpecified = true;
            message.ToRecipients = new EmailAddressType[1];
            message.ToRecipients[0] = address;
            BodyType body = new BodyType();
            body.Value = Common.GenerateResourceName(this.Site, "Test Mail Body");
            message.Body = body;

            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[1];
            createItemRequest.Items.Items[0] = message;
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            ItemInfoResponseMessageType itemInfo = (ItemInfoResponseMessageType)createItemResponse.ResponseMessages.Items[0];

            // Return item id.
            if (itemInfo.Items.Items != null)
            {
                return itemInfo.Items.Items[0].ItemId;
            }
            else
            {
                return null;
            }
        }
 public void MSOXWSCORE_S04_TC16_GetEmailItemWithBodyTypeResponseTypeEnum()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyGetItemWithItemResponseShapeType_BodyTypeResponseTypeEnum(item);
 }
        public void MSOXWSCORE_S04_TC17_VerifyEmailWithResponseObjects()
        {
            #region Step 1: Create a message with IsReadReceiptRequested.
            // Define the MessageType item which will be created.
            MessageType[] messages = new MessageType[] { new MessageType() };
            messages[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            EmailAddressType email = new EmailAddressType();
            email.EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            messages[0].ToRecipients = new EmailAddressType[1];
            messages[0].ToRecipients[0] = email;
            messages[0].IsReadReceiptRequestedSpecified = true;
            messages[0].IsReadReceiptRequested = true;

            // Define the request of CreateItem operation.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            requestItem.Items.Items = messages;

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 2: Get the message with response objects in inbox.
            // Find the received item in the Inbox folder.
            ItemIdType[] foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, messages[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                foundItems,
                "The result of FindItemsInFolder should not be null.");

            // One item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 foundItems.GetLength(0),
                 "One item should be returned! Expected count: {0}, actual count: {1}",
                 1,
                 foundItems.GetLength(0));

            // Get information from the found item.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(foundItems);

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

            // Check whether the child elements of ResponseObjects have been returned successfully.
            ItemInfoResponseMessageType getItems = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            ResponseObjectType[] responseObjects = getItems.Items.Items[0].ResponseObjects;
 
            Site.Assert.IsNotNull(responseObjects, "The ResponseObjects should not be null.");

            // Receivers could reply, reply all, forward or send read receipt for the received item, so there should be four child elements in ResponseObjects.
            Site.Assert.AreEqual<int>(
                4,
                responseObjects.Length,
                "Four child elements in ResponseObjects should be returned! Expected count: {0}, actual count: {1}",
                4,
                responseObjects.Length);

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

            // The type of the child element should be ReplyToItemType, ForwardItemType, ReplyAllToItemType or SuppressReadReceiptType.
            foreach (ResponseObjectType responseObject in responseObjects)
            {
                if (responseObject.GetType() == typeof(ReplyToItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1371");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1371
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1371,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ReplyToItem is t:ReplyToItemType ([MS-OXWSCDATA] section 2.2.4.56).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R131
                    // The response object with ReplyToItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        131,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ReplyToItem""] Specifies a reply to the sender of an item.");
                }
                else if (responseObject.GetType() == typeof(ForwardItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1372");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1372
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1372,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ForwardItem is t:ForwardItemType ([MS-OXWSCDATA] section 2.2.4.33).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R132
                    // The response object with ForwardItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        132,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ForwardItem""] Specifies a server store item to be forwarded to recipients.");
                }
                else if (responseObject.GetType() == typeof(ReplyAllToItemType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1373");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1373
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1373,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of ReplyAllToItem is t:ReplyAllToItemType ([MS-OXWSCDATA] section 2.2.4.54).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R133
                    // The response object with ReplyAllToItemType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        133,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""ReplyAllToItem""] Specifies a reply to the sender and all identified recipients of an item in the server store.");
                }
                else if (responseObject.GetType() == typeof(SuppressReadReceiptType))
                {
                    // Add the debug information
                    this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1376");

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1376
                    // The schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirement(
                        1376,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] The type of SuppressReadReceipt is t:SuppressReadReceiptType ([MS-OXWSCDATA] section 2.2.4.61).");

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

                    // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R136
                    // The response object with SuppressReadReceiptType type is not null and the schema is validated, so this requirement can be captured.
                    this.Site.CaptureRequirementIfIsNotNull(
                        responseObject,
                        136,
                        @"[In t:NonEmptyArrayOfResponseObjectsType Complex Type] [The element ""SuppressReadReceipt""] Specifies that read receipts are to be suppressed.");
                }
                else
                {
                    Site.Assume.Fail(
                        string.Format(
                        "The type of responseObject should be one of the following types: ReplyToItemType, ForwardItemType, ReplyAllToItemType or SuppressReadReceiptType, actual {0}",
                        responseObject.GetType()));
                }
            }
            #endregion

            #region Step 3: Delete messages in inbox.
            // Delete the created item.
            this.COREAdapter.DeleteItem(new DeleteItemType() { DeleteType = DisposalType.HardDelete, ItemIds = foundItems });
            this.ExistItemIds.Clear();
            this.FindNewItemsInFolder(DistinguishedFolderIdNameType.inbox);
            #endregion
        }
        public void MSOXWSCORE_S04_TC25_UpdateItemWithSuppressReadReceipts()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2315, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute.");

            #region Send an email with setting IsReadReceiptRequested to true.

            MessageType message = new MessageType();
            message.IsReadReceiptRequestedSpecified = true;
            message.IsReadReceiptRequested = true;
            message.ToRecipients = new EmailAddressType[1];
            EmailAddressType recipient = new EmailAddressType();
            recipient.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            message.ToRecipients[0] = recipient;
            message.From = new SingleRecipientType
            {
                Item = new EmailAddressType
                {
                    EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site)
                }
            };
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { message };
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1);
            createItemRequest.MessageDisposition = MessageDispositionType.SendOnly;
            createItemRequest.MessageDispositionSpecified = true;
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            ItemIdType[] findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Update the found email with setting SuppressReadReceipts to true.

            ItemChangeType[] itemChanges = new ItemChangeType[1];
            itemChanges[0] = new ItemChangeType();
            itemChanges[0].Item = findItemIds[0];
            itemChanges[0].Updates = new ItemChangeDescriptionType[1];
            SetItemFieldType setItemFiled = new SetItemFieldType();
            setItemFiled.Item = new PathToUnindexedFieldType()
            {
                FieldURI = UnindexedFieldURIType.messageIsRead
            };
            setItemFiled.Item1 = new MessageType()
            {
                IsRead = true,
                IsReadSpecified = true
            };
            itemChanges[0].Updates[0] = setItemFiled;
            UpdateItemType updateItemType = new UpdateItemType();
            updateItemType.ItemChanges = itemChanges;
            updateItemType.ConflictResolution = ConflictResolutionType.AutoResolve;
            updateItemType.MessageDisposition = MessageDispositionType.SaveOnly;
            updateItemType.MessageDispositionSpecified = true;
            updateItemType.SuppressReadReceipts = true;
            updateItemType.SuppressReadReceiptsSpecified = true;
            UpdateItemResponseType updateItemResponse = this.COREAdapter.UpdateItem(updateItemType);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.IsNull(findItemIds, "The read receipt email should not be received if receiver update the email with setting SuppressReadReceipts to true.");

            List<string> subjects = new List<string>();
            subjects.Add(createItemRequest.Items.Items[0].Subject);
            this.ExistItemIds.Clear();
            #endregion

            #region Send an email with setting IsReadReceiptRequested to true.

            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2);
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Update the found email with setting SuppressReadReceipts to false.

            updateItemType.ItemChanges[0].Item = findItemIds[0];
            updateItemType.SuppressReadReceipts = false;
            updateItemResponse = this.COREAdapter.UpdateItem(updateItemType);
            Common.CheckOperationSuccess(updateItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.AreEqual<int>(1, findItemIds.Length, "The read receipt email should not be received if receiver update the email with setting SuppressReadReceipts to true.");
            subjects.Add(createItemRequest.Items.Items[0].Subject);
            this.ExistItemIds.Clear();
            this.ExistItemIds.Add(findItemIds[0]);
            this.CleanItemsSentOut(subjects.ToArray());

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2315
            // This requirement can be captured directly after above steps.
            this.Site.CaptureRequirement(
                2315,
                @"[In Appendix C: Product Behavior] Implementation does  support the SuppressReadReceipts attribute specifies whether read receipts are suppressed. (<102> Section 3.1.4.9.3.2:  This attribute [SuppressReadReceipts] was introduced in Exchange 2013 SP1.)");
            #endregion
        }
        public void MSOXWSCORE_S04_TC14_GetEmailItemWithBlockExternalImages()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2149905, this.Site), "Exchange 2007 and Exchange 2010 do not use the BlockExternalImages element.");

            MessageType item = new MessageType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_BlockExternalImagesBoolean(item);
        }
        public void MSOXWSCORE_S04_TC23_VerifyPublicFolderItem()
        {
            FolderIdType folderId = null;

            FindFolderType findRequest = new FindFolderType();
            findRequest.FolderShape = new FolderResponseShapeType();
            findRequest.FolderShape.BaseShape = DefaultShapeNamesType.AllProperties;
            DistinguishedFolderIdType id = new DistinguishedFolderIdType();
            id.Id = DistinguishedFolderIdNameType.publicfoldersroot;
            findRequest.ParentFolderIds = new DistinguishedFolderIdType[] { id };
            findRequest.Traversal = FolderQueryTraversalType.Shallow;

            BaseFolderType[] folders = null;
            FindFolderResponseType findFolderResponse = this.SRCHAdapter.FindFolder(findRequest);
            FindFolderResponseMessageType findFolderResponseMessageType = new FindFolderResponseMessageType();
            if (findFolderResponse != null && findFolderResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
            {
                findFolderResponseMessageType = findFolderResponse.ResponseMessages.Items[0] as FindFolderResponseMessageType;
                folders = findFolderResponseMessageType.RootFolder.Folders;
                foreach (BaseFolderType folder in folders)
                {
                    if (folder.DisplayName.Equals(Common.GetConfigurationPropertyValue("PublicFolderName", this.Site)))
                    {
                        folderId = folder.FolderId;
                    }
                }
            }

            Site.Assert.IsNotNull(
                folderId,
                "The destination public folder {0} in should exist!",
                Common.GetConfigurationPropertyValue("PublicFolderName", this.Site));

            MessageType message = new MessageType();
            MessageType[] items = new MessageType[] { message };
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SaveOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            requestItem.Items.Items = items;

            requestItem.SavedItemFolderId = new TargetFolderIdType();

            requestItem.SavedItemFolderId.Item = folderId;

            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(requestItem);

            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            ItemInfoResponseMessageType itemInfo = (ItemInfoResponseMessageType)createItemResponse.ResponseMessages.Items[0];
            ItemIdId itemId = this.ITEMIDAdapter.ParseItemId(itemInfo.Items.Items[0].ItemId);

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

            // Verify MS-OXWSITEMID requirement: MS-OXWSITEMID_R62
            Site.CaptureRequirementIfAreEqual<IdStorageType>(
                IdStorageType.PublicFolderItem,
                itemId.StorageType,
                "MS-OXWSITEMID",
                62,
                @"[In Id Storage Type (byte)] Its [Id Storage Type's] value maps to the following enumeration value.
                    /// <summary>
                    /// Indicates which type of storage is used for the item/folder represented by this Id.
                    /// </summary>
                    internal enum IdStorageType : byte
                    {
                [        /// <summary>
                        /// The Id represents an item or folder in a mailbox and 
                        /// it contains a primary SMTP address. 
                        /// </summary>
                        MailboxItemSmtpAddressBased = 0,

                        /// <summary>
                        /// The Id represents a folder in a PublicFolder store.
                        /// </summary>
                        PublicFolder = 1,]

                        /// <summary>
                        /// The Id represents an item in a PublicFolder store.
                        /// </summary>
                        PublicFolderItem = 2,
                [
                        /// <summary>
                        /// The Id represents an item or folder in a mailbox and contains a mailbox GUID.
                        /// </summary>
                        MailboxItemMailboxGuidBased = 3,

                        /// <summary>
                        /// The Id represents a conversation in a mailbox and contains a mailbox GUID.
                        /// </summary>
                        ConversationIdMailboxGuidBased = 4,

                        /// <summary>
                        /// The Id represents (by objectGuid) an object in the Active Directory.
                        /// </summary>
                        ActiveDirectoryObject = 5,]
                }");
        }
        public void MSOXWSCORE_S04_TC24_DeleteItemWithSuppressReadReceipts()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2311, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute.");

            #region Send an email with setting IsReadReceiptRequested to true.

            MessageType message = new MessageType();
            message.IsReadReceiptRequestedSpecified = true;
            message.IsReadReceiptRequested = true;
            message.ToRecipients = new EmailAddressType[1];
            EmailAddressType recipient = new EmailAddressType();
            recipient.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            message.ToRecipients[0] = recipient;
            message.From = new SingleRecipientType
            {
                Item = new EmailAddressType
                {
                    EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site)
                }
            };
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { message };
            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1);
            createItemRequest.MessageDisposition = MessageDispositionType.SendOnly;
            createItemRequest.MessageDispositionSpecified = true;
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            ItemIdType[] findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Delete the found email with setting SuppressReadReceipts to true.

            DeleteItemType deleteItemRequest = new DeleteItemType();
            deleteItemRequest.ItemIds = findItemIds;
            deleteItemRequest.DeleteType = DisposalType.HardDelete;
            deleteItemRequest.SuppressReadReceiptsSpecified = true;
            deleteItemRequest.SuppressReadReceipts = true;
            DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.IsNull(findItemIds, "The read receipt email should not be received if receiver delete the email with setting SuppressReadReceipts to true.");

            #endregion

            #region Send an email with setting IsReadReceiptRequested to true.

            createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2);
            createItemResponse = this.COREAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

            #endregion

            #region Find the email in receiver's inbox.

            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2");
            Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email.");

            #endregion

            #region Delete the found email with setting SuppressReadReceipts to false.

            deleteItemRequest.ItemIds = findItemIds;
            deleteItemRequest.SuppressReadReceipts = false;
            deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest);
            Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site);
            findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1");
            Site.Assert.AreEqual<int>(1, findItemIds.Length, "The read receipt email should be received if receiver delete the email with setting SuppressReadReceipts to false.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2311
            // This requirement can be captured directly after above steps.
            this.Site.CaptureRequirement(
                2311,
                @"[In Appendix C: Product Behavior] Implementation does support the SuppressReadReceipts attribute which specifies whether read receipts are suppressed. (Exchange 2013 SP1 and above follow this behavior.)");

            #endregion
        }
        public void MSOXWSCORE_S04_TC22_VerifyItemWithEntityExtractionResult()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1708, this.Site), "Exchange 2007 and Exchange 2010 do not support the EntityExtractionResultType complex type.");

            #region Step 1: Create message with specific body.

            // Define the specific elements' values.
            string meetingSuggestions = "Let's meet for business discussion, from 2:00pm to 2:30pm, December 15th, 2012.";
            string address = "1234 Main Street, Redmond, WA 07722";
            string taskSuggestions = "Please update the spreadsheet by today.";
            string phoneNumbers = "(235) 555-0110";
            string phoneNumberType = "Home";
            string businessName = "Department of Revenue Services";
            string contactDisplayName = TestSuiteHelper.ContactString;
            string emailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            string url = Common.GetConfigurationPropertyValue("ServiceUrl", this.Site);
            string userEmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // Define the MessageType item which will be created.
            MessageType[] messages = new MessageType[] { new MessageType() };
            messages[0].Subject = Common.GenerateResourceName(
                this.Site,
                TestSuiteHelper.SubjectForCreateItem);
            EmailAddressType email = new EmailAddressType();
            email.EmailAddress = userEmailAddress;
            messages[0].ToRecipients = new EmailAddressType[1];
            messages[0].ToRecipients[0] = email;
            messages[0].Body = new BodyType();
            messages[0].Body.Value = string.Format(
                "{0} {1} Any problems, contact with {2} from {3}, his {4} phone number is {5}, his email is {6}, his blog is {7} and his address is {8}",
                meetingSuggestions,
                taskSuggestions,
                contactDisplayName,
                businessName,
                phoneNumberType,
                phoneNumbers,
                emailAddress,
                url,
                address);

            // Define the request of CreateItem operation.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            requestItem.Items.Items = messages;

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 2: Find the message in the inbox folder of User1.
            // Find the received item in the Inbox folder.
            ItemIdType[] foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, messages[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                foundItems,
                "The result of FindItemsInFolder should not be null.");

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

            #region Step 3: Get the message.
            // Get information from the found items.
            GetItemResponseType getItemResponse = this.CallGetItemOperation(foundItems);

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

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

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

            // Check whether the child elements of EntityExtractionResultType have been returned successfully.
            ItemInfoResponseMessageType getItems = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

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

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1325
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                getItems.Items.Items[0].InternetMessageHeaders,
                1325,
                @"[In t:ItemType Complex Type] The type of InternetMessageHeaders is t:NonEmptyArrayOfInternetHeadersType (section 2.2.4.12).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R122
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirement(
                122,
                @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] The type [NonEmptyArrayOfInternetHeadersType] is defined as follow:
<xs:complexType name=""NonEmptyArrayOfInternetHeadersType"">
  <xs:sequence>
    <xs:element name=""InternetMessageHeader""
      type=""t:InternetHeaderType""
      maxOccurs=""unbounded""
     />
  </xs:sequence>
</xs:complexType>");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R20301
            // MS-OXWSCORE_R1325 is captured, this requirement can be captured directly.
            this.Site.CaptureRequirement(
                20301,
                @"[In t:ItemType Complex Type] It [InternetMessageHeaders] can be retrieved by GetItem (section 3.1.4.4) operation.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1367
            // The schema is validated and InternetMessageHeaders is not null, so this requirement can be captured.
            this.Site.CaptureRequirement(
                1367,
                @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] The type of InternetMessageHeader is t:InternetHeaderType([MS-OXWSCDATA] section 2.2.4.35).");

            foreach (InternetHeaderType internetMessageHeader in getItems.Items.Items[0].InternetMessageHeaders)
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1674");

                // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R1674
                // The schema is validated and the internetMessageHeader is not null, so this requirement can be captured.
                this.Site.CaptureRequirementIfIsNotNull(
                    internetMessageHeader,
                    "MS-OXWSCDATA",
                    1674,
                    @"[In t:InternetHeaderType Complex Type] The attribute ""HeaderName"" is ""xs:string"" type.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R88");
                this.Site.Log.Add(LogEntryKind.Debug, "The HeaderName should not be null, actual {0}.", internetMessageHeader.HeaderName);
                this.Site.Log.Add(LogEntryKind.Debug, "The Value should not be null, actual {0}.", internetMessageHeader.Value);

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R88
                // The schema is validated and the child elements in internetMessageHeader are not null, so this requirement can be captured.
                bool isVerifiedR88 = internetMessageHeader.HeaderName != null && internetMessageHeader.Value != null;

                this.Site.CaptureRequirementIfIsTrue(
                    isVerifiedR88,
                    88,
                    @"[In t:ItemType Complex Type] [The element ""InternetMessageHeaders""] Specifies an array of the type InternetHeaderType that represents the collection of all Internet message headers that are contained in an item in a mailbox.");

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

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R124
                this.Site.CaptureRequirement(
                    124,
                    @"[In t:NonEmptyArrayOfInternetHeadersType Complex Type] [The element ""InternetMessageHeader""] Specifies a single Internet message header.");
            }

            EntityExtractionResultType entityExtractionResult = getItems.Items.Items[0].EntityExtractionResult;

            // Verify EntityExtractionResultType structure.
            this.VerifyEntityExtractionResultType(entityExtractionResult);

            // Verify ArrayOfAddressEntitiesType structure.
            this.VerifyArrayOfAddressEntitiesType(entityExtractionResult.Addresses, address);

            // Verify ArrayOfMeetingSuggestionsType structure.
            // "2:00pm, December 15th, 2012" is supposed to be "2012/12/15 14:00:00" in dataTime type.
            // "2:30pm, December 15th, 2012" is supposed to be "2012/12/15 14:30:00" in dataTime type.
            this.VerifyArrayOfMeetingSuggestionsType(entityExtractionResult.MeetingSuggestions, meetingSuggestions, DateTime.Parse("2012/12/15 14:00:00"), DateTime.Parse("2012/12/15 14:30:00"), Common.GetConfigurationPropertyValue("User1Name", this.Site), userEmailAddress);

            // Verify ArrayOfTaskSuggestionsType structure.
            this.VerifyArrayOfTaskSuggestionsType(entityExtractionResult.TaskSuggestions, taskSuggestions, Common.GetConfigurationPropertyValue("User1Name", this.Site), userEmailAddress);

            // Verify ArrayOfEmailAddressEntitiesType structure.
            this.VerifyArrayOfEmailAddressEntitiesType(entityExtractionResult.EmailAddresses, emailAddress);

            // Verify ArrayOfContactsType structure.
            Uri uri = new Uri(url);
            this.VerifyArrayOfContactsType(entityExtractionResult.Contacts, contactDisplayName, businessName, uri, phoneNumbers, phoneNumberType, emailAddress, address);

            // Verify ArrayOfUrlEntitiesType structure.
            this.VerifyArrayOfUrlEntitiesType(entityExtractionResult.Urls, uri);

            // Verify ArrayOfPhoneEntitiesType structure.
            this.VerifyArrayOfPhoneEntitiesType(entityExtractionResult.PhoneNumbers, phoneNumbers, phoneNumberType);
            #endregion
        }
        public void MSOXWSCORE_S04_TC21_VerifyItemWithIsDraftAndIsUnmodified()
        {
            #region Step 1: Create the item which will be saved.
            // Define the MessageType item to create.
            EmailAddressType addressTo = new EmailAddressType();
            addressTo.EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            EmailAddressType addressCc = new EmailAddressType();
            addressCc.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);
            MessageType[] message = new MessageType[1]
            {
                new MessageType
                {
                    ToRecipients = new EmailAddressType[] { addressTo, addressCc },
                    CcRecipients = new EmailAddressType[] { addressCc, addressTo },
                    Subject = Common.GenerateResourceName(this.Site, "ItemSaveOnly")
                }
            };

            // Call the CreateItem operation.
            CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.inbox, message);

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

            ItemIdType[] createdItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

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

            #region Step 2: Get the created item.
            // 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 item should be returned.
            Site.Assert.AreEqual<int>(
                 1,
                 getItemIds.GetLength(0),
                 "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

            // If the item is saved, the IsDraft element should be true and the IsUnmodified element should be false.
            ItemInfoResponseMessageType itemInfoResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            ArrayOfRealItemsType arrayOfRealItemsType = itemInfoResponseMessage.Items;

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

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1608, Expected result:{0}, Actual result:{1}", true, arrayOfRealItemsType.Items[0].IsDraft);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1608
            bool isVerifiedR1608 = arrayOfRealItemsType.Items[0].IsDraftSpecified && arrayOfRealItemsType.Items[0].IsDraft;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1608,
                1608,
                @"[In t:ItemType Complex Type] [IsDraft is] True, indicates an item has not been sent.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1615, Expected result:{0}, Actual result:{1}", false, arrayOfRealItemsType.Items[0].IsUnmodified);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1615
            bool isVerifiedR1615 = arrayOfRealItemsType.Items[0].IsUnmodifiedSpecified && !arrayOfRealItemsType.Items[0].IsUnmodified;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1615,
                1615,
                @"[In t:ItemType Complex Type] otherwise [IsUnmodified is] false, indicates [an item has been modified].");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R96
            // The schema is validated, the DisplayCc element is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                arrayOfRealItemsType.Items[0].DisplayCc,
                96,
                @"[In t:ItemType Complex Type] [The element ""DisplayCc""] Specifies the display string that is used for the contents of the Cc box.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R97
            // The schema is validated, the DisplayCc element is concatenated by the display names of all Cc recipients, so this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual<string>(
                (Common.GetConfigurationPropertyValue("User2Name", this.Site) + "; " + Common.GetConfigurationPropertyValue("User1Name", this.Site)).ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                arrayOfRealItemsType.Items[0].DisplayCc.ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                97,
                @"[In t:ItemType Complex Type] This [DisplayCc] is the concatenated string of all Cc recipient display names.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R98
            // The schema is validated, the DisplayTo element is not null, so this requirement can be captured.
            this.Site.CaptureRequirementIfIsNotNull(
                arrayOfRealItemsType.Items[0].DisplayTo,
                98,
                @"[In t:ItemType Complex Type] [The element ""DisplayTo""] Specifies the display string that is used for the contents of the To box.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R99
            // The schema is validated, the DisplayTo element is concatenated by the display names of all To recipients, so this requirement can be captured.
            this.Site.CaptureRequirementIfAreEqual<string>(
                (Common.GetConfigurationPropertyValue("User1Name", this.Site) + "; " + Common.GetConfigurationPropertyValue("User2Name", this.Site)).ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                arrayOfRealItemsType.Items[0].DisplayTo.ToUpper(new CultureInfo(TestSuiteHelper.Culture, false)),
                99,
                @"[In t:ItemType Complex Type] This [DisplayTo] is the concatenated string of all To recipient display names.");
            #endregion

            #region Step 3: Create the item which will be sent.
            // Define the CreateItem request.
            CreateItemType requestItem = new CreateItemType();
            requestItem.MessageDispositionSpecified = true;
            requestItem.MessageDisposition = MessageDispositionType.SendOnly;
            requestItem.Items = new NonEmptyArrayOfAllItemsType();
            message = new MessageType[1]
            {
                new MessageType
                {
                    ToRecipients = new EmailAddressType[] { addressTo },
                    Subject = Common.GenerateResourceName(this.Site, "ItemSendOnly")
                }
            };
            requestItem.Items.Items = message;

            // Call the CreateItem operation.
            createItemResponse = this.COREAdapter.CreateItem(requestItem);

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

            #region Step 4: Get the received item.
            // Find the received item in the Inbox folder.
            ItemIdType[] findItem = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, message[0].Subject, "User1");

            // The result of FindItemsInFolder should not be null.
            Site.Assert.IsNotNull(
                findItem,
                "The result of FindItemsInFolder should not be null.");

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

            // Get the found item.
            getItemResponse = this.CallGetItemOperation(findItem);

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

            getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse);

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

            // If the item is sent, the IsDraft element should be false and the IsUnmodified element should be true.
            itemInfoResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
            arrayOfRealItemsType = itemInfoResponseMessage.Items;

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

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1609, Expected result:{0}, Actual result:{1}", false, arrayOfRealItemsType.Items[0].IsDraft);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1609
            bool isVerifiedR1609 = arrayOfRealItemsType.Items[0].IsDraftSpecified && !arrayOfRealItemsType.Items[0].IsDraft;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1609,
                1609,
                @"[In t:ItemType Complex Type] otherwise [IsDraft is] false, indicates [an item has been sent].");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1614, Expected result:{0}, Actual result:{1}", true, arrayOfRealItemsType.Items[0].IsUnmodified);

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1614
            bool isVerifiedR1614 = arrayOfRealItemsType.Items[0].IsUnmodifiedSpecified && arrayOfRealItemsType.Items[0].IsUnmodified;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR1614,
                1614,
                @"[In t:ItemType Complex Type] [IsUnmodified is] True, indicates an item has not been modified.");
            #endregion
        }
        public void MSOXWSCORE_S04_TC03_MoveEmailItemSuccessfully()
        {
            #region Step 1: Create the message type item.
            MessageType item = new MessageType();
            ItemIdType[] createdItemIds = this.CreateItemWithMinimumElements(item);
            #endregion

            #region Step 2: Move the message type 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 message type item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 movedItemIds.GetLength(0),
                 "One moved message type item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 movedItemIds.GetLength(0));
            #endregion

            #region Step 3: Get the created message type 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 message type item operation should be failed with error! Actual response code: {0}",
                    getItemResponse.ResponseMessages.Items[0].ResponseCode));
            #endregion

            #region Step 4:Get the moved message type 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 message type item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One message type item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));

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

            MessageType item = new MessageType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_ConvertHtmlCodePageToUTF8Boolean(item);
        }
        public void MSOXWSCORE_S04_TC05_MarkAllEmailItemsAsReadSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1290, this.Site), "Exchange 2007 and Exchange 2010 do not support the MarkAllItemsAsRead operation.");

            MessageType[] items = new MessageType[] { new MessageType(), new MessageType() };
            this.TestSteps_VerifyMarkAllItemsAsRead(items);
        }
        public void MSOXWSCORE_S04_TC13_GetEmailItemWithAddBlankTargetToLinks()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2149908, this.Site), "Exchange 2007 and Exchange 2010 do not use the AddBlankTargetToLinks element.");

            MessageType item = new MessageType();
            this.TestSteps_VerifyGetItemWithItemResponseShapeType_AddBlankTargetToLinksBoolean(item);
        }
 public void MSOXWSCORE_S04_TC06_UpdateEmailItemSuccessfully()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyUpdateItemSuccessfulResponse(item);
 }
 public void MSOXWSCORE_S04_TC15_GetEmailItemWithDefaultShapeNamesTypeEnum()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyGetItemWithItemResponseShapeType_DefaultShapeNamesTypeEnum(item);
 }
 public void MSOXWSCORE_S04_TC07_UpdateEmailItemFailed()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyUpdateItemFailedResponse(item);
 }
        public void MSOXWSCORE_S04_TC02_CopyEmailItemSuccessfully()
        {
            #region Step 1:Create the message type item
            MessageType item = new MessageType();
            ItemIdType[] createdItemIds = this.CreateItemWithMinimumElements(item);
            #endregion

            #region Step 2:Copy the message type 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 message type item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 copiedItemIds.GetLength(0),
                 "One copied message type item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 copiedItemIds.GetLength(0));
            #endregion

            #region Step 3:Get the first created message type 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 message type item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One message type item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));
            #endregion

            #region Step 4:Get the second copied message type 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 message type item should be returned.
            Site.Assert.AreEqual<int>(
                1,
                 getItemIds.GetLength(0),
                 "One message type item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                 1,
                 getItemIds.GetLength(0));
            #endregion
        }
        public void MSOXWSCORE_S04_TC08_VerifyExtendPropertyType()
        {
            MessageType item = new MessageType();
            this.TestSteps_VerifyDistinguishedPropertySetIdConflictsWithPropertySetId(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyDistinguishedPropertySetIdConflictsWithPropertyTag(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyDistinguishedPropertySetIdWithPropertyTypeOrPropertyName(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertySetIdConflictsWithDistinguishedPropertySetId(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertySetIdConflictsWithPropertyTag(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertySetIdWithPropertyTypeOrPropertyName(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyTagRepresentation(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyTagConflictsWithDistinguishedPropertySetId(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyTagConflictsWithPropertyName(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyTagConflictsWithPropertyId(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyNameWithDistinguishedPropertySetIdOrPropertySetId(DistinguishedFolderIdNameType.inbox, item);

            this.TestSteps_VerifyPropertyIdWithDistinguishedPropertySetIdOrPropertySetId(DistinguishedFolderIdNameType.inbox, item);
        }
        public void MSOXWSCORE_S04_TC18_MarkAsJunkSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(1787, this.Site), "Exchange 2007 and Exchange 2010 do not use the MarkAsJunk operation");

            #region Create the successful message
            MessageType[] items = new MessageType[]
            {
                new MessageType
                {
                    Sender = new SingleRecipientType
                    {
                        Item = new EmailAddressType
                        {
                            EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site)
                        }
                    },

                    Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem),
                }
            };

            string itemSubject = items[0].Subject;
            string itemSender = items[0].Sender.Item.EmailAddress;

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

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

            MarkAsJunkType markAsJunkRequest = new MarkAsJunkType();
            markAsJunkRequest.ItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);
            markAsJunkRequest.IsJunk = true;
            markAsJunkRequest.MoveItem = true;

            MarkAsJunkResponseType markAsJunkResponse = this.COREAdapter.MarkAsJunk(markAsJunkRequest);

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

            MarkAsJunkResponseMessageType markAsJunkResponseMessage = (MarkAsJunkResponseMessageType)markAsJunkResponse.ResponseMessages.Items[0];

            if (Common.IsRequirementEnabled(1787, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1787");

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1787
                this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                    ResponseClassType.Success,
                    markAsJunkResponseMessage.ResponseClass,
                    1787,
                    @"[In Appendix C: Product Behavior] Implementation does use [The operation ""MarkAsJunk""] which Marks an item as junk. (Exchange 2013 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(1790, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1790");

                // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1790
                this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                    ResponseClassType.Success,
                    markAsJunkResponseMessage.ResponseClass,
                    1790,
                    @"[In Appendix C: Product Behavior] Implementation does use the MarkAsJunk operation which marks an item as junk. (Exchange 2013 and above follow this behavior.)");
            }

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1844
            this.Site.CaptureRequirementIfIsNotNull(
                markAsJunkResponse,
                1844,
                @"[In m:MarkAsJunkResponseType Complex Type] This type [MarkAsJunkResponseType Complex Type] extends the BaseResponseMessageType, as specified in [MS-OXWSCDATA] section 2.2.4.16.");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1847
            this.Site.CaptureRequirementIfIsNotNull(
                markAsJunkResponseMessage,
                1847,
                @"[In m:MarkAsJunkResponseMessageType Complex Type] This type [MarkAsJunkResponseMessageType Complex Type] extends the ResponseMessageType complex type, as specified in [MS-OXWSCDATA] section 2.2.4.57.");

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

            // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R3060
            this.Site.CaptureRequirementIfIsNotNull(
                markAsJunkResponseMessage,
                "MS-OXWSCDATA",
                3060,
                @"[In m:ArrayOfResponseMessagesType Complex Type] The element ""MarkAsJunkResponseMessage"" with type ""m:MarkAsJunkResponseMessageType ([MS-OXWSCORE] section 3.1.4.6.3.3)"" specifies the response message for the MarkAsJunk operation ([MS-OXWSCORE] section 3.1.4.6).");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1850
            this.Site.CaptureRequirementIfIsInstanceOfType(
                markAsJunkResponseMessage.MovedItemId,
                typeof(ItemIdType),
                1850,
                @"[In m:MarkAsJunkResponseMessageType Complex Type] The type of MovedItemId is t:ItemIdType (section 2.2.4.19).");

            ItemIdType[] getItemIds = new ItemIdType[] { markAsJunkResponseMessage.MovedItemId };
            GetItemResponseType getItemResponse = this.CallGetItemOperation(getItemIds);

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

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1851
            // When use the MovedItemId to get item and only one item is returned in the response, it means that the MovedItemId specifies an identifier of the moved item, thus this requirement can be verified.
            this.Site.CaptureRequirement(
                1851,
                @"[In m:MarkAsJunkResponseMessageType Complex Type] [The child element ""MovedItemId""] Specifies the item identifier of the moved item. ");

            // Find the item in the Junk Email folder.
            ItemIdType[] foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.junkemail, itemSubject, "User1");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1920
            // Since the value of IsJunk is true and the value of MoveItem is true, the item is moved to the Junk Email folder. Thus the response of FindItem should not be null, then this requirement can be verified.
            this.Site.CaptureRequirementIfIsNotNull(
                foundItems,
                1920,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] True and [the value of ""MoveItem"" is] True, The operation moves the email item to the Junk Email folder. ");
            
            string blockedSender = null;
            string userName = Common.GetConfigurationPropertyValue("User1Name", this.Site);
            blockedSender = this.CORESUTControlAdapter.GetMailboxJunkEmailConfiguration(userName);

            bool isInBlockedSender = blockedSender.Contains(itemSender);

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1839
            this.Site.CaptureRequirementIfIsTrue(
                isInBlockedSender,
                1839,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] True and [the value of ""MoveItem"" is] True, the operation adds the sender of the email to the blocked sender list and moves the email item to the Junk Email folder.");

            markAsJunkRequest.ItemIds = foundItems;
            markAsJunkRequest.IsJunk = true;
            markAsJunkRequest.MoveItem = false;
            markAsJunkResponse = this.COREAdapter.MarkAsJunk(markAsJunkRequest);

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

            // Find the item in the Junk Email folder.
            foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.junkemail, itemSubject, "User1");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1921
            // Since the value of IsJunk is true and the value of MoveItem is false, the item is still in the Junk Email folder. Thus the response of FindItem should not be null, then this requirement can be verified.
            this.Site.CaptureRequirementIfIsNotNull(
                foundItems,
                1921,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] True and [the value of ""MoveItem"" is] False,The email item is not moved.");

            blockedSender = this.CORESUTControlAdapter.GetMailboxJunkEmailConfiguration(userName);
            isInBlockedSender = blockedSender.Contains(itemSender);

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1840
            this.Site.CaptureRequirementIfIsTrue(
                isInBlockedSender,
                1840,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] True and [the value of ""MoveItem"" is] False, the operation adds the sender of the email to the blocked sender list.");

            markAsJunkRequest.ItemIds = foundItems;
            markAsJunkRequest.IsJunk = false;
            markAsJunkRequest.MoveItem = true;
            markAsJunkResponse = this.COREAdapter.MarkAsJunk(markAsJunkRequest);

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

            // Find the item in the Inbox folder.
            foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, itemSubject, "User1");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1922
            // Since the value of IsJunk is false and the value of MoveItem is true, the item is moved to the inbox folder. Thus the response of FindItem should not be null, then this requirement can be verified.
            this.Site.CaptureRequirementIfIsNotNull(
                foundItems,
                1922,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] False and [the value of ""MoveItem"" is] True, The operation moves the email item back to the Inbox folder.");

            blockedSender = this.CORESUTControlAdapter.GetMailboxJunkEmailConfiguration(userName);
            isInBlockedSender = blockedSender.Contains(itemSender);

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1841
            this.Site.CaptureRequirementIfIsFalse(
                isInBlockedSender,
                1841,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] False and [the value of ""MoveItem"" is] True, the operation removes the sender from the blocked sender list.");

            markAsJunkRequest.ItemIds = foundItems;
            markAsJunkRequest.IsJunk = false;
            markAsJunkRequest.MoveItem = false;
            markAsJunkResponse = this.COREAdapter.MarkAsJunk(markAsJunkRequest);

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

            // Find the item in the Inbox folder.
            foundItems = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, itemSubject, "User1");

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1923
            // Since the value of IsJunk is false and the value of MoveItem is false, the item is still in the Inbox folder. Thus the response of FindItem should not be null, then this requirement can be verified.
            this.Site.CaptureRequirementIfIsNotNull(
                foundItems,
                1923,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] False and [the value of ""MoveItem"" is] False, The email item is not moved.");

            blockedSender = this.CORESUTControlAdapter.GetMailboxJunkEmailConfiguration(userName);
            isInBlockedSender = blockedSender.Contains(itemSender);

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1842
            this.Site.CaptureRequirementIfIsFalse(
                isInBlockedSender,
                1842,
                @"[In m:MarkAsJunkType Complex Type] [When the value of ""IsJunk"" is] False and [the value of ""MoveItem"" is] False, the operation removes the sender from the blocked sender list.");

            this.ExistItemIds.Clear();
            this.ExistItemIds.Add(foundItems[0]);
            #endregion
        }
        public void MSOXWSCORE_S04_TC09_OperateMultipleEmailItemsSuccessfully()
        {
            #region Step 1: Create multiple items.
            EmailAddressType address = new EmailAddressType()
            {
                EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site),
            };

            MessageType[] items = new MessageType[]
            {
                new MessageType
                {
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForCreateItem,
                        1),

                    ToRecipients = new EmailAddressType[]
                    {
                        address
                    }
                },
                new MessageType
                {
                    Subject = Common.GenerateResourceName(
                        this.Site,
                        TestSuiteHelper.SubjectForCreateItem,
                        2),

                    ToRecipients = new EmailAddressType[]
                    {
                        address
                    }
                }
            };

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

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

            ItemType[] createdItems = Common.GetItemsFromInfoResponse<ItemType>(createItemResponse);

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

            #region Step 2 - 5: Update, move, get and copy the items.
            this.OperateMultipleItems(createdItems);
            #endregion

            #region Step 6: Send the items and clean the items sent out.
            // Call SendItem to send the created message items from Inbox folder to the recipient identified by the ToRecipients element, by using createdItemIds in CreateItem response.
            ItemIdType[] itemArray = new ItemIdType[this.CopiedItemIds.Count];
            this.CopiedItemIds.CopyTo(itemArray, 0);
            SendItemResponseType sendResponse = this.CallSendItemOperation(
                itemArray,
                DistinguishedFolderIdNameType.sentitems,
                false);

            // Check the operation response.
            Common.CheckOperationSuccess(sendResponse, 2, this.Site);

            // Remove the sent items from ExistItemIds collection, since the items have been sent out and no copy remains.
            foreach (ItemIdType itemId in itemArray)
            {
                this.ExistItemIds.Remove(itemId);
            }

            // Clear the sent items.
            string[] itemSubjects = new string[2];
            itemSubjects[0] = items[0].Subject;
            itemSubjects[1] = items[1].Subject;
            this.CleanItemsSentOut(itemSubjects);
            #endregion
        }
Exemplo n.º 24
0
        /// <summary>
        /// Verify the requirements about MessageType properties.
        /// </summary>
        /// <param name="messageItem">An instance of MessageType type.</param>
        /// <param name="isSchemaValidated">The result of schema validation, true means valid.</param>
        private void VerifyMessageType(MessageType messageItem, bool isSchemaValidated)
        {
            if (messageItem.Sender != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R25");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R25
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    25,
                    @"[In t:MessageType Complex Type] The Sender element is t:SingleRecipientType ([MS-OXWSCDATA] section 2.2.4.71) type.");

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

                // Verify MS-OXWSMSG requirement: MS-OXWSCDATA_R1292   
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    "MS-OXWSCDATA",
                    1292,
                    @"[In t:SingleRecipientType Complex Type] The type [SingleRecipientType] is defined as follow:
 <xs:complexType name=""SingleRecipientType"">
  <xs:choice>
    <xs:element name=""Mailbox""
      type=""t:EmailAddressType""
     />
  </xs:choice>
</xs:complexType>");
            }

            if (messageItem.ToRecipients != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R29");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R29
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    29,
                    @"[In t:MessageType Complex Type] ToRecipients element is t:ArrayOfRecipientsType ([MS-OXWSCDATA] section 2.2.4.11) type.");

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

                // Verify MS-OXWSMSG requirement: MS-OXWSCDATA_R1033 
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    "MS-OXWSCDATA",
                    1033,
                    @"[In t:ArrayOfRecipientsType Complex Type] The type [ArrayOfRecipientsType] is defined as follow:
 <xs:complexType name=""ArrayOfRecipientsType"">
  <xs:choice
    maxOccurs=""unbounded""
    minOccurs=""0""
  >
    <xs:element name=""Mailbox""
      type=""t:EmailAddressType""
     />
  </xs:choice>
</xs:complexType>");
            }

            if (messageItem.CcRecipients != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R184");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R184
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    184,
                    @"[In t:MessageType Complex Type] CcRecipients element is t:ArrayOfRecipientsType type.");
            }

            if (messageItem.BccRecipients != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R185");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R185
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    185,
                    @"[In t:MessageType Complex Type] BccRecipients element is t:ArrayOfRecipientsType type.");
            }

            if (messageItem.IsReadReceiptRequestedSpecified)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R186");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R186
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    186,
                    @"[In t:MessageType Complex Type] IsReadReceiptRequested element is xs:boolean ([XMLSCHEMA2] sec 3.2.2) type.");
            }

            if (messageItem.IsDeliveryReceiptRequestedSpecified)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R187");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R187
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    187,
                    @"[In t:MessageType Complex Type] IsDeliveryReceiptRequested element is xs:boolean type.");
            }

            if (messageItem.ConversationIndex != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R188");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R188
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    188,
                    @"[In t:MessageType Complex Type] ConversationIndex element is xs:base64Binary ([XMLSCHEMA2] sec 3.2.16) type.");
            }

            if (messageItem.ConversationTopic != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R189");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R189
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    189,
                    @"[In t:MessageType Complex Type] ConversationTopic element is xs:string ([XMLSCHEMA2] sec 3.2.1) type.");
            }

            if (messageItem.ApprovalRequestData != null && Common.IsRequirementEnabled(182002, Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R73002");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R73002
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    73002,
                    @"[In t:MessageType Complex Type] The type of child element ApprovalRequestData is t:ApprovalRequestDataType ([MS-OXWSMTGS] section 2.2.4.3).");
            }

            if (messageItem.VotingInformation != null && Common.IsRequirementEnabled(182004, Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R73004");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R73004
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    73004,
                    @"[In t:MessageType Complex Type] The type of child element VotingInformation is t:VotingInformationType ([MS-OXWSMTGS] section 2.2.4.39)."); 
            }

            if (messageItem.ReminderMessageData != null && Common.IsRequirementEnabled(182006, Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R73006");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R73006
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    73006,
                    @"[In t:MessageType Complex Type] The type of child element ReminderMessageData is t:ReminderMessageDataType ( [MS-OXWSMTGS] section 2.2.4.33).");  
            }
            
            if (messageItem.From != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R190");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R190
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    190,
                    @"[In t:MessageType Complex Type] From element is t:SingleRecipientType type.");
            }

            if (messageItem.InternetMessageId != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R191");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R191
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    191,
                    @"[In t:MessageType Complex Type] InternetMessageId element is xs:string type.");
            }

            if (messageItem.IsReadSpecified)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R192");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R192
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    192,
                    @"[In t:MessageType Complex Type] IsRead element is xs:boolean type.");
            }

            if (messageItem.IsResponseRequestedSpecified)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R193");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R193
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    193,
                    @"[In t:MessageType Complex Type] IsResponseRequested element is xs:boolean type.");
            }

            if (messageItem.References != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R194");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R194
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    194,
                    @"[In t:MessageType Complex Type] References element is xs:string type.");
            }

            if (messageItem.ReplyTo != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R195");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R195
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    195,
                    @"[In t:MessageType Complex Type] ReplyTo element is t:ArrayOfRecipientsType type.");
            }

            if (messageItem != null)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R22");

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R22
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    22,
                    @"[In t:MessageType Complex Type] The MessageType complex type extends the ItemType complex type ([MS-OXWSCORE] section 2.2.4.24).");

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

                // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R23
                Site.CaptureRequirementIfIsTrue(
                    isSchemaValidated,
                    23,
                    @"[In t:MessageType Complex Type] The MessageType schema is <xs:complexType name=""MessageType"">
  <xs:complexContent>
    <xs:extension
      base=""t:ItemType""
    >
      <xs:sequence>
        <xs:element name=""Sender""
          type=""t:SingleRecipientType""
          minOccurs=""0""
         />
        <xs:element name=""ToRecipients""
          type=""t:ArrayOfRecipientsType""
          minOccurs=""0""
         />
        <xs:element name=""CcRecipients""
          type=""t:ArrayOfRecipientsType""
          minOccurs=""0""
         />
        <xs:element name=""BccRecipients""
          type=""t:ArrayOfRecipientsType""
          minOccurs=""0""
         />
        <xs:element name=""IsReadReceiptRequested""
          type=""xs:boolean""
          minOccurs=""0""
         />
        <xs:element name=""IsDeliveryReceiptRequested""
          type=""xs:boolean""
          minOccurs=""0""
         />
        <xs:element name=""ConversationIndex""
          type=""xs:base64Binary""
          minOccurs=""0""
         />
        <xs:element name=""ConversationTopic""
          type=""xs:string""
          minOccurs=""0""
         />
        <xs:element name=""From""
          type=""t:SingleRecipientType""
          minOccurs=""0""
         />
        <xs:element name=""InternetMessageId""
          type=""xs:string""
          minOccurs=""0""
         />
        <xs:element name=""IsRead""
          type=""xs:boolean""
          minOccurs=""0""
         />
        <xs:element name=""IsResponseRequested""
          type=""xs:boolean""
          minOccurs=""0""
         />
        <xs:element name=""References""
          type=""xs:string""
          minOccurs=""0""
         />
        <xs:element name=""ReplyTo""
          type=""t:ArrayOfRecipientsType""
          minOccurs=""0""
         />
        <xs:element name=""ReceivedBy""
          type=""t:SingleRecipientType""
          minOccurs=""0""
         />
        <xs:element name=""ReceivedRepresenting""
          type=""t:SingleRecipientType""
          minOccurs=""0""
         />
        <xs:element name=""ApprovalRequestData""
	          type=""t:ApprovalRequestDataType"" 
	          minOccurs=""0""
	     />
	     <xs:element name=""VotingInformation""
	          type=""t:VotingInformationType"" 
	          minOccurs=""0""
	     />
	     <xs:element name=""ReminderMessageData"" 
	          type=""t:ReminderMessageDataType"" 
	          minOccurs=""0""
	     />
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>");
            }

            if (messageItem.Sender != null && messageItem.Sender.Item != null)
            {
                this.VerifyEmailAddressType(messageItem.Sender.Item, isSchemaValidated);
            }

            if (messageItem.From != null && messageItem.From.Item != null)
            {
                this.VerifyEmailAddressType(messageItem.From.Item, isSchemaValidated);
            }

            if (messageItem.ReceivedBy != null && messageItem.ReceivedBy.Item != null)
            {
                this.VerifyEmailAddressType(messageItem.ReceivedBy.Item, isSchemaValidated);
            }

            if (messageItem.ReceivedRepresenting != null && messageItem.ReceivedRepresenting.Item != null)
            {
                this.VerifyEmailAddressType(messageItem.ReceivedRepresenting.Item, isSchemaValidated);
            }
        }
 public void MSOXWSCORE_S04_TC01_CreateGetDeleteEmailItemSuccessfully()
 {
     MessageType item = new MessageType();
     this.TestSteps_VerifyCreateGetDeleteItem(item);
 }
        public void MSOXWSSYNC_S02_TC01_SyncFolderItems_MessageType()
        {
            #region Step 1. Client invokes SyncFolderItems operation to get the initial syncState of inbox folder.
            DistinguishedFolderIdNameType inboxFolder = DistinguishedFolderIdNameType.inbox;

            // Set DefaultShapeNamesType to AllProperties
            SyncFolderItemsType request = this.CreateSyncFolderItemsRequestWithoutOptionalElements(inboxFolder, DefaultShapeNamesType.AllProperties);

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

            #region Step 2. Client invokes CreateItem operation to create a MessageType item on server and get its id.
            MessageType messageType = new MessageType();
            BaseItemIdType[] itemIds = this.CreateItem(inboxFolder, messageType);
            #endregion

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

            // 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.");

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

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R70
            Site.CaptureRequirementIfIsNotNull(
                changes,
                70,
                @"[In m:SyncFolderItemsResponseMessageType Complex Type] [The element Changes] specifies the differences between the items on the client and the items on the server.");

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

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

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R156
            Site.CaptureRequirementIfIsInstanceOfType(
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item,
                typeof(MessageType),
                156,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] The type of Message is t:MessageType ([MS-OXWSMSG] section 2.2.4.1).");

            Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one MessageType item was created in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");
            bool isMessageTypeItemCreated = changes.ItemsElementName[0] == ItemsChoiceType1.Create &&
                    (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(MessageType);

            // If the ItemsElementName of Changes is Create and the type of Item is MessageType, it indicates a message has been created on server and synced on client, 
            // then requirements MS-OXWSSYNC_R131 and MS-OXWSSYNC_R1571 can be captured
            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R131. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}",
                ItemsChoiceType1.Create,
                typeof(MessageType),
                changes.ItemsElementName[0],
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType());

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R131
            Site.CaptureRequirementIfIsTrue(
                isMessageTypeItemCreated,
                131,
                @"[In t:SyncFolderItemsChangesType Complex Type] [The element Create] specifies an item that has been created on the server and has to be created on the client.");

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

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1571
            Site.CaptureRequirementIfIsTrue(
                isMessageTypeItemCreated,
                1571,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element Message] specifies a message to create in the client message store.");
            #endregion

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

            #region Step 5. Client invokes SyncFolderItems operation with previous SyncState  to sync the operation result in Step 4 and verify related requirements.
            responseMessage = this.GetResponseMessage(inboxFolder, 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 MessageType 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 MessageType item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");

            bool isItemSubjectUpdated = false;
            isItemSubjectUpdated = changes.ItemsElementName[0] == ItemsChoiceType1.Update &&
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.Subject == newItemSubject;

            // If the ItemsElementName of Changes is Update and the item's subject is a new value, it indicates the message type item has been updated on server and synced on client.
            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R132. Expected value: ItemsElementName: {0}, item subject: {1}; actual value: ItemsElementName: {2}, item subject: {3}",
                ItemsChoiceType1.Update,
                newItemSubject,
                changes.ItemsElementName[0],
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.Subject);

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R132
            Site.CaptureRequirementIfIsTrue(
                isItemSubjectUpdated,
                132,
                @"[In t:SyncFolderItemsChangesType Complex Type] [The element Update] specifies an item that has been changed on the server and has to be changed on the client.");

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

            // If the ItemsElementName of Changes is Update and the type of Item is MessageType, it indicates a message has been updated on server and synced on client.
            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R1572. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}",
                ItemsChoiceType1.Update,
                typeof(MessageType),
                changes.ItemsElementName[0],
                (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType());

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1572
            Site.CaptureRequirementIfIsTrue(
                isMessageUpdated,
                1572,
                @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element Message] specifies a message to  update in the client message store.");
            #endregion

            #region Step 6. Client invokes UpdateItem operation to change the IsRead property of the item that updated in Step 4.
            // Call UpdateReadFlag to update the IsRead property.
            this.UpdateReadFlag(itemIds, this.ConvertReadFlag(itemIds));
            #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(inboxFolder, 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 MessageType 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 MessageType item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");

            bool isUpdateReadFlag = changes.ItemsElementName[0] == ItemsChoiceType1.ReadFlagChange && changes.Items[0].GetType() == typeof(SyncFolderItemsReadFlagType);

            // If the ItemsElementName of changes is ReadFlagChange and the type of item in changes is SyncFolderItemsReadFlagType, 
            // it indicates the read flag has been updated on server and synced on client.
            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R136. Expected value: ItemsElementName: {0}, change items type: {1}; actual value: ItemsElementName: {2}, change items type: {3}",
                ItemsChoiceType1.ReadFlagChange,
                typeof(SyncFolderItemsReadFlagType),
                changes.ItemsElementName[0],
                changes.Items[0].GetType());

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R136
            Site.CaptureRequirementIfIsTrue(
                isUpdateReadFlag,
                136,
                @"[In t:SyncFolderItemsChangesType Complex Type] [The element ReadFlagChange] specifies an item that has been marked as read on the server and has to be marked as read on the client.");
            #endregion

            #region Step 8. Client invokes DeleteItem operation to delete the item which the IsRead property is updated in Step 6.
            this.DeleteItem(itemIds);
            #endregion

            #region Step 9. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 8 and verify related requirements.
            responseMessage = this.GetResponseMessage(inboxFolder, 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 MessageType item was deleted 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 MessageType item was deleted in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");

            bool isItemDeleted = (changes.ItemsElementName[0] == ItemsChoiceType1.Delete) && (changes.Items[0].GetType() == typeof(SyncFolderItemsDeleteType));

            // If the ItemsElementName is Delete and the items type in changes is SyncFolderItemsDeleteType, it indicates a MessageType item has been deleted on server and synced on client. 
            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXWSSYNC_R134. Expected value: ItemsElementName: {0}, change items type: {1}; actual value: ItemsElementName: {2}, change items type: {3}",
                ItemsChoiceType1.Delete,
                typeof(SyncFolderItemsDeleteType),
                changes.ItemsElementName[0],
                changes.Items[0].GetType());

            // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R134
            Site.CaptureRequirementIfIsTrue(
                isItemDeleted,
                134,
                @"[In t:SyncFolderItemsChangesType Complex Type] [The element Delete] specifies an item that has been deleted on the server and has to be deleted on the client.");
            #endregion
        }
        public void MSOXWSMTGS_S02_TC11_UpdateItemErrorMessageDispositionRequired()
        {
            #region Create a message without setting MessageDisposition element.
            CreateItemType createItemRequest = new CreateItemType();
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new ItemType[] { new MessageType() };
            createItemRequest.Items.Items[0].Subject = this.Subject;
            DistinguishedFolderIdType folderIdForCreateItems = new DistinguishedFolderIdType();
            folderIdForCreateItems.Id = DistinguishedFolderIdNameType.drafts;
            createItemRequest.SavedItemFolderId = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = folderIdForCreateItems;
            CreateItemResponseType createItemResponse = this.MTGSAdapter.CreateItem(createItemRequest);

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1241
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                createItemResponse.ResponseMessages.Items[0].ResponseClass,
                1241,
                @"[In Messages] ErrorMessageDispositionRequired:This error code MUST be returned under the following conditions: 
                  When the item that is being created or updated is a MessageType object. 
                  [For the CancelCalendarItemType, AcceptItemType, DeclineItemType, or TentativelyAcceptItemType response objects.]");
            #endregion

            #region Create a message with setting MessageDisposition element.
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.MessageDispositionSpecified = true;
            createItemResponse = this.MTGSAdapter.CreateItem(createItemRequest);
            Common.CheckOperationSuccess(createItemResponse, 1, this.Site);
            #endregion

            #region Update the message without setting MessageDisposition element.
            MessageType messageUpdate = new MessageType();
            messageUpdate.Subject = this.SubjectUpdate;

            UpdateItemType updateItemRequest = new UpdateItemType();
            updateItemRequest.ItemChanges = new ItemChangeType[1];
            PathToUnindexedFieldType pathToUnindexedField = new PathToUnindexedFieldType();
            pathToUnindexedField.FieldURI = UnindexedFieldURIType.itemSubject;
            SetItemFieldType setItemField = new SetItemFieldType();
            setItemField.Item = pathToUnindexedField;
            setItemField.Item1 = messageUpdate;
            ItemChangeType itemChange = new ItemChangeType();
            itemChange.Item = (createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType).Items.Items[0].ItemId;
            itemChange.Updates = new ItemChangeDescriptionType[] { setItemField };
            updateItemRequest.ItemChanges[0] = itemChange;
            UpdateItemResponseType updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest);

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1237
            this.Site.CaptureRequirementIfAreEqual<ResponseClassType>(
                ResponseClassType.Error,
                updateItemResponse.ResponseMessages.Items[0].ResponseClass,
                1237,
                @"[In Messages] If the request is unsuccessful, the UpdateItem operation returns an UpdateItemResponse element with the ResponseClass attribute of the UpdateItemResponseMessage element set to ""Error"". ");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1240
            this.Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorMessageDispositionRequired,
                updateItemResponse.ResponseMessages.Items[0].ResponseCode,
                1240,
                @"[In Messages] ErrorMessageDispositionRequired: Occurs if the MessageDisposition property is not set. ");

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

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1241
            this.Site.CaptureRequirementIfAreEqual<ResponseCodeType>(
                ResponseCodeType.ErrorMessageDispositionRequired,
                updateItemResponse.ResponseMessages.Items[0].ResponseCode,
                1241,
                @"[In Messages] ErrorMessageDispositionRequired:This error code MUST be returned under the following conditions: 
                  When the item that is being created or updated is a MessageType object. 
                  [For the CancelCalendarItemType, AcceptItemType, DeclineItemType, or TentativelyAcceptItemType response objects.]");
            #endregion

            #region Clean up organizer's drafts folders.
            this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.drafts });
            #endregion
        }