/// <summary>
        /// Move items to the specific folder.
        /// </summary>
        /// <param name="serverIds">The ServerId of the items to move.</param>
        /// <param name="sourceFolder">The CollectionId of the source folder.</param>
        /// <param name="destinationFolder">The CollectionId of the destination folder.</param>
        /// <returns>The response of MoveItems command.</returns>
        protected MoveItemsResponse CallMoveItemsCommand(Collection <string> serverIds, string sourceFolder, string destinationFolder)
        {
            // Move the items from sourceFolder to destinationFolder.
            List <Request.MoveItemsMove> moveItems = new List <Request.MoveItemsMove>();

            foreach (string serverId in serverIds)
            {
                Request.MoveItemsMove move = new Request.MoveItemsMove
                {
                    SrcFldId = sourceFolder,
                    DstFldId = destinationFolder,
                    SrcMsgId = serverId
                };

                moveItems.Add(move);
            }

            MoveItemsRequest moveItemsRequest = Common.CreateMoveItemsRequest(moveItems.ToArray());

            // Call MoveItems command to move the items.
            MoveItemsResponse moveItemsResponse = this.CONAdapter.MoveItems(moveItemsRequest);

            Site.Assert.AreEqual <int>(serverIds.Count, moveItemsResponse.ResponseData.Response.Length, "The count of Response element should be {0}, actual {1}.", serverIds.Count, moveItemsResponse.ResponseData.Response.Length);
            foreach (Response.MoveItemsResponse response in moveItemsResponse.ResponseData.Response)
            {
                Site.Assert.AreEqual <int>(3, int.Parse(response.Status), "If the MoveItems command executes successfully, the Status should be 3, actual {0}.", response.Status);
            }

            return(moveItemsResponse);
        }
        public void MSASCMD_S21_TC04_CommonStatusCode_105()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The DstFldId element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User2 sends mail to User1 and do FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server, and get the ServerId of sent email item and the SyncKey
            SyncResponse syncResponseInbox = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            string       serverId          = TestSuiteBase.FindServerId(syncResponseInbox, "Subject", subject);
            #endregion

            #region Call method MoveItems with the email item's ServerId to move the email item from Inbox folder to recipient information cache.
            Request.MoveItemsMove moveItemsMove = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.RecipientInformationCacheCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };

            MoveItemsRequest  moveItemsRequest  = Common.CreateMoveItemsRequest(new Request.MoveItemsMove[] { moveItemsMove });
            MoveItemsResponse moveItemsResponse = this.CMDAdapter.MoveItems(moveItemsRequest);
            #endregion

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4821
            Site.CaptureRequirementIfAreEqual <int>(
                105,
                int.Parse(moveItemsResponse.ResponseData.Response[0].Status),
                4821,
                @"[In Common Status Codes] [The meaning of the status value 105 is] The request contains a combination of parameters that is invalid.");
        }
Esempio n. 3
0
        public void MSASCMD_S10_TC07_MoveItems_Status103()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5671, this.Site), "Exchange 2007 does not limit the number of elements in command requests.");

            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server, and get the ServerId of sent email item and the SyncKey
            SyncResponse syncResponseInbox = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);
            string syncKeyInbox = this.LastSyncKey;
            string serverId     = TestSuiteBase.FindServerId(syncResponseInbox, "Subject", subject);
            #endregion

            #region Call method Sync to synchronize changes of DeletedItems folder in User1's mailbox between the client and the server, and get the SyncKey
            this.SyncChanges(this.User1Information.DeletedItemsCollectionId);
            string syncKeyDeletedItems = this.LastSyncKey;
            #endregion

            #region Call method MoveItems with the email item's ServerId to move the email item from Inbox folder to DeletedItems folder.
            Request.MoveItemsMove moveItemsMove = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.DeletedItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };

            Request.MoveItems moveItems = new Request.MoveItems();
            moveItems.Move = new Request.MoveItemsMove[1001];
            for (int i = 0; i <= 1000; i++)
            {
                moveItems.Move[i] = moveItemsMove;
            }

            MoveItemsRequest  request     = new MoveItemsRequest();
            Request.MoveItems requestData = moveItems;
            request.RequestData = requestData;

            MoveItemsResponse moveItemsResponse = this.CMDAdapter.MoveItems(request);

            this.Site.CaptureRequirementIfAreEqual <int>(
                103,
                int.Parse(moveItemsResponse.ResponseData.Status),
                5653,
                @"[In Limiting Size of Command Requests] In MoveItems (section 2.2.2.11) command request, when the limit value of Move element is bigger than 1000 (minimum 1, maximum 2,147,483,647), the error returned by server is Status element (section 2.2.3.167.9) value of 103.");
            #endregion
        }
        /// <summary>
        /// Call MoveItems command to move an item to another location.
        /// </summary>
        /// <param name="itemServerId">The ServerId of the email to move.</param>
        /// <param name="sourceFolder">The ServerId of the folder to move from.</param>
        /// <param name="destinationFolder">The ServerId of the folder to move to.</param>
        protected void CallMoveItemsCommand(string itemServerId, string sourceFolder, string destinationFolder)
        {
            Request.MoveItemsMove[] moveItemsMove = new Request.MoveItemsMove[1];
            moveItemsMove[0] = new Request.MoveItemsMove
            {
                DstFldId = destinationFolder,
                SrcFldId = sourceFolder,
                SrcMsgId = itemServerId
            };

            MoveItemsRequest request = Common.CreateMoveItemsRequest(moveItemsMove);
            SendStringResponse moveItemsResponse = this.HTTPAdapter.HTTPPOST(CommandName.MoveItems, null, request.GetRequestDataSerializedXML());

            // Check the command is executed successfully.
            this.CheckResponseStatus(moveItemsResponse.ResponseDataXML);
        }
        public void MSASCMD_S10_TC07_MoveItems_Status103()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5671, this.Site), "Exchange 2007 does not limit the number of elements in command requests.");

            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server, and get the ServerId of sent email item and the SyncKey
            SyncResponse syncResponseInbox = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);
            string syncKeyInbox = this.LastSyncKey;
            string serverId = TestSuiteBase.FindServerId(syncResponseInbox, "Subject", subject);
            #endregion

            #region Call method Sync to synchronize changes of DeletedItems folder in User1's mailbox between the client and the server, and get the SyncKey
            this.SyncChanges(this.User1Information.DeletedItemsCollectionId);
            string syncKeyDeletedItems = this.LastSyncKey;
            #endregion

            #region Call method MoveItems with the email item's ServerId to move the email item from Inbox folder to DeletedItems folder.
            Request.MoveItemsMove moveItemsMove = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.DeletedItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };

            Request.MoveItems moveItems = new Request.MoveItems();
            moveItems.Move = new Request.MoveItemsMove[1001];
            for (int i = 0; i <= 1000; i++)
            {
                moveItems.Move[i] = moveItemsMove;
            }

            MoveItemsRequest request = new MoveItemsRequest();
            Request.MoveItems requestData = moveItems;
            request.RequestData = requestData;

            MoveItemsResponse moveItemsResponse = this.CMDAdapter.MoveItems(request);

            this.Site.CaptureRequirementIfAreEqual<int>(
                103,
                int.Parse(moveItemsResponse.ResponseData.Status),
                5653,
                @"[In Limiting Size of Command Requests] In MoveItems (section 2.2.2.11) command request, when the limit value of Move element is bigger than 1000 (minimum 1, maximum 2,147,483,647), the error returned by server is Status element (section 2.2.3.167.9) value of 103.");
            #endregion
        }
        public void MSASCMD_S10_TC06_MoveItems_Status5()
        {
            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server.
            SyncResponse syncResponseInbox = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            string syncKeyInbox = this.LastSyncKey;
            string serverId = TestSuiteBase.FindServerId(syncResponseInbox, "Subject", subject);
            #endregion

            #region Call method Sync to synchronize changes of DeletedItems folder in User1's mailbox between the client and the server.
            this.SyncChanges(this.User1Information.DeletedItemsCollectionId);
            string syncKeyDeletedItems = this.LastSyncKey;
            #endregion

            #region Call method Sync to synchronize changes of SentItems folder in User1's mailbox between the client and the server.
            this.SyncChanges(this.User1Information.SentItemsCollectionId);
            string syncKeySentItems = this.LastSyncKey;
            #endregion

            #region Call method MoveItems with the email item's ServerId and two different destination collection IDs to move the same email item from Inbox folder to two different folders, and check if there is one response with Status element equal to 5
            MoveItemsRequest moveItemsRequest = new MoveItemsRequest();
            Request.MoveItems moveItems = new Request.MoveItems();
            List<Request.MoveItemsMove> moveItemList = new List<Request.MoveItemsMove>();

            Request.MoveItemsMove moveItemsMoveOne = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.DeletedItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };
            moveItemList.Add(moveItemsMoveOne);

            Request.MoveItemsMove moveItemsMoveTwo = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.SentItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };

            moveItemList.Add(moveItemsMoveTwo);

            moveItems.Move = moveItemList.ToArray();

            moveItemsRequest.RequestData = moveItems;

            MoveItemsResponse moveItemsResponse = this.CMDAdapter.MoveItems(moveItemsRequest);

            this.CheckMoveItemsResponse(moveItemsResponse, 2);

            bool hasStatus5 = false;
            bool hasStatus3 = false;
            foreach (Response.MoveItemsResponse response in moveItemsResponse.ResponseData.Response)
            {
                if (int.Parse(response.Status) == 5)
                {
                    hasStatus5 = true;
                    Site.Log.Add(LogEntryKind.Debug, "There should be at least one Status element equal to 5 in MoveItems response");
                }
                else if (int.Parse(response.Status) == 3)
                {
                    hasStatus3 = true;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4222
            Site.CaptureRequirementIfIsTrue(
                hasStatus5,
                4222,
                @"[In Status(MoveItems)] [When the scope is Global], [the cause of the status value 5 is] More than one DstFldId element (section 2.2.3.47.2) was included in the request [or an item with that name already exists].");

            #endregion

            #region Call method Sync to synchronize changes of Inbox folder, DeletedItems and SentItems folder in User1's mailbox, and record the item changes in case there is another success response.
            if (hasStatus3)
            {
                bool isItemDeleted = this.CheckDeleteInSyncResponse(syncKeyInbox, this.User1Information.InboxCollectionId, serverId);
                Site.Assert.IsTrue(isItemDeleted, "The item with ServerId: {0} should be deleted for collection ID: {1}.", serverId, this.User1Information.InboxCollectionId);
                TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);

                bool isItemAddedDeleteItems = this.CheckAddInSyncResponse(syncKeyDeletedItems, this.User1Information.DeletedItemsCollectionId, subject);
                if (isItemAddedDeleteItems)
                {
                    Site.Log.Add(LogEntryKind.Debug, "The item with ServerId: {0} has been added for Deleted Items folder", serverId);
                    TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.DeletedItemsCollectionId, subject);
                }

                bool isItemAddedSentItems = this.CheckAddInSyncResponse(syncKeySentItems, this.User1Information.SentItemsCollectionId, subject);
                if (isItemAddedSentItems)
                {
                    Site.Log.Add(LogEntryKind.Debug, "The item with ServerId: {0} has been added for Sent Items folder", serverId);
                    TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.SentItemsCollectionId, subject);
                }

                Site.Assert.AreNotEqual<bool>(
                    isItemAddedDeleteItems,
                    isItemAddedSentItems,
                    "If the source item is moved successfully, it should exist in either Deleted Items folder or Sent Items folder, but should not exist in both of these folders.");
            }
            #endregion
        }
        /// <summary>
        /// This method is used to create MoveItems request.
        /// </summary>
        /// <param name="srcMsgId">The server ID of the item to be moved.</param>
        /// <param name="srcFldId">The server ID of the source folder.</param>
        /// <param name="dstFldId">The server ID of the destination folder.</param>
        /// <returns>The MoveItems request.</returns>
        protected static MoveItemsRequest CreateMoveItemsRequest(string srcMsgId, string srcFldId, string dstFldId)
        {
            Request.MoveItemsMove moveItemsMove = new Request.MoveItemsMove
            {
                DstFldId = dstFldId,
                SrcFldId = srcFldId,
                SrcMsgId = srcMsgId
            };

            return Common.CreateMoveItemsRequest(new Request.MoveItemsMove[] { moveItemsMove });
        }
Esempio n. 8
0
        public void MSASCMD_S10_TC06_MoveItems_Status5()
        {
            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server.
            SyncResponse syncResponseInbox = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            string       syncKeyInbox      = this.LastSyncKey;
            string       serverId          = TestSuiteBase.FindServerId(syncResponseInbox, "Subject", subject);
            #endregion

            #region Call method Sync to synchronize changes of DeletedItems folder in User1's mailbox between the client and the server.
            this.SyncChanges(this.User1Information.DeletedItemsCollectionId);
            string syncKeyDeletedItems = this.LastSyncKey;
            #endregion

            #region Call method Sync to synchronize changes of SentItems folder in User1's mailbox between the client and the server.
            this.SyncChanges(this.User1Information.SentItemsCollectionId);
            string syncKeySentItems = this.LastSyncKey;
            #endregion

            #region Call method MoveItems with the email item's ServerId and two different destination collection IDs to move the same email item from Inbox folder to two different folders, and check if there is one response with Status element equal to 5
            MoveItemsRequest             moveItemsRequest = new MoveItemsRequest();
            Request.MoveItems            moveItems        = new Request.MoveItems();
            List <Request.MoveItemsMove> moveItemList     = new List <Request.MoveItemsMove>();

            Request.MoveItemsMove moveItemsMoveOne = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.DeletedItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };
            moveItemList.Add(moveItemsMoveOne);

            Request.MoveItemsMove moveItemsMoveTwo = new Request.MoveItemsMove
            {
                DstFldId = this.User1Information.SentItemsCollectionId,
                SrcFldId = this.User1Information.InboxCollectionId,
                SrcMsgId = serverId
            };

            moveItemList.Add(moveItemsMoveTwo);

            moveItems.Move = moveItemList.ToArray();

            moveItemsRequest.RequestData = moveItems;

            MoveItemsResponse moveItemsResponse = this.CMDAdapter.MoveItems(moveItemsRequest);

            this.CheckMoveItemsResponse(moveItemsResponse, 2);

            bool hasStatus5 = false;
            bool hasStatus3 = false;
            foreach (Response.MoveItemsResponse response in moveItemsResponse.ResponseData.Response)
            {
                if (int.Parse(response.Status) == 5)
                {
                    hasStatus5 = true;
                    Site.Log.Add(LogEntryKind.Debug, "There should be at least one Status element equal to 5 in MoveItems response");
                }
                else if (int.Parse(response.Status) == 3)
                {
                    hasStatus3 = true;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4222
            Site.CaptureRequirementIfIsTrue(
                hasStatus5,
                4222,
                @"[In Status(MoveItems)] [When the scope is Global], [the cause of the status value 5 is] More than one DstFldId element (section 2.2.3.47.2) was included in the request [or an item with that name already exists].");

            #endregion

            #region Call method Sync to synchronize changes of Inbox folder, DeletedItems and SentItems folder in User1's mailbox, and record the item changes in case there is another success response.
            if (hasStatus3)
            {
                bool isItemDeleted = this.CheckDeleteInSyncResponse(syncKeyInbox, this.User1Information.InboxCollectionId, serverId);
                Site.Assert.IsTrue(isItemDeleted, "The item with ServerId: {0} should be deleted for collection ID: {1}.", serverId, this.User1Information.InboxCollectionId);
                TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);

                bool isItemAddedDeleteItems = this.CheckAddInSyncResponse(syncKeyDeletedItems, this.User1Information.DeletedItemsCollectionId, subject);
                if (isItemAddedDeleteItems)
                {
                    Site.Log.Add(LogEntryKind.Debug, "The item with ServerId: {0} has been added for Deleted Items folder", serverId);
                    TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.DeletedItemsCollectionId, subject);
                }

                bool isItemAddedSentItems = this.CheckAddInSyncResponse(syncKeySentItems, this.User1Information.SentItemsCollectionId, subject);
                if (isItemAddedSentItems)
                {
                    Site.Log.Add(LogEntryKind.Debug, "The item with ServerId: {0} has been added for Sent Items folder", serverId);
                    TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.SentItemsCollectionId, subject);
                }

                Site.Assert.AreNotEqual <bool>(
                    isItemAddedDeleteItems,
                    isItemAddedSentItems,
                    "If the source item is moved successfully, it should exist in either Deleted Items folder or Sent Items folder, but should not exist in both of these folders.");
            }
            #endregion
        }