Microsoft.Protocols.TestSuites.MS_ASCMD.S10_MoveItems.MSASCMD_S10_TC06_MoveItems_Status5 C# (CSharp) Method

MSASCMD_S10_TC06_MoveItems_Status5() private method

private MSASCMD_S10_TC06_MoveItems_Status5 ( ) : void
return void
        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
        }