public void MSASCMD_S02_TC04_FolderCreate_Status5()
        {
            // Set a parentFolderID that doesn't exist in request.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "InvalidParentId");

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

            // If the parent folder does not exist on the server, the value of the Status element should be 5.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4019
            Site.CaptureRequirementIfAreEqual <int>(
                5,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4019,
                @"[In Status(FolderCreate)] [When the scope is Item], [the cause of the status value 5 is] The parent folder does not exist on the server, possibly because it has been deleted or renamed.");

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

            // If the parent folder does not exist on the server, the value of the Status element should be 5.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4018
            Site.CaptureRequirementIfAreEqual <int>(
                5,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4018,
                @"[In Status(FolderCreate)] [When the scope is] Item, [the meaning of the status value] 5 [is] The specified parent folder was not found.");
        }
        public void MSASCMD_S05_TC04_FolderUpdate_Status5()
        {
            // Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");

            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);

            // Call method FolderUpdate to move the folder to a nonexistent parent folder.
            FolderUpdateRequest  folderUpdateRequest  = Common.CreateFolderUpdateRequest(folderCreateResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId, Common.GenerateResourceName(Site, "FolderUpdate"), "InvalidParentId");
            FolderUpdateResponse folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);

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

            // If calls method FolderUpdate to move the folder to a nonexistent parent folder, server will return status 5.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4108
            Site.CaptureRequirementIfAreEqual <int>(
                5,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                4108,
                @"[In Status(FolderUpdate)] [When the scope is] Item, [the meaning of the status value] 5 [is] The specified parent folder was not found.");

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

            // If calls method FolderUpdate to move the folder to a nonexistent parent folder, server will return status 5.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4109
            Site.CaptureRequirementIfAreEqual <int>(
                5,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                4109,
                @"[In Status(FolderUpdate)] [When the scope is Item], [the cause of the status value 5 is] Client specified a nonexistent folder in a FolderUpdate command request.");
        }
        public void MSASCMD_S02_TC07_FolderCreate_Status3()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The recipient information cache 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.");

            // Set the specified parent folder is the recipient information cache
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), User1Information.RecipientInformationCacheCollectionId);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4016
            Site.CaptureRequirementIfAreEqual <int>(
                3,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4016,
                @"[In Status(FolderCreate)] [When the scope is Item], [the cause of the status value 3 is] The specified parent folder is the Recipient information folder.");

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

            // Since server return status 3, the FolderCreate command cannot be used to update a recipient information cache.
            // Verify MS-ASCMD requirement: MS-ASCMD_R5769
            Site.CaptureRequirement(
                5769,
                @"[In FolderCreate] The FolderCreate command cannot be used to create [a recipient information cache or] a subfolder of a recipient information cache.");
        }
        public void MSASCMD_S02_TC05_FolderCreate_Status9()
        {
            // Call method FolderCreate to create a new folder with invalid folder SyncKey.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse("InvalidFolderSyncKey", (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");

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

            // If the client sent a malformed or mismatched synchronization key in FolderCreate request, the value of the Status element should be 9.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4032
            Site.CaptureRequirementIfAreEqual <int>(
                9,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4032,
                @"[In Status(FolderCreate)] [When the scope is Global], [the cause of the status value 9 is] The client sent a malformed or mismatched synchronization key, or the synchronization state is corrupted on the server.");

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

            // If the client sent a malformed or mismatched synchronization key in FolderCreate request, the value of the Status element should be 9.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4573
            Site.CaptureRequirementIfAreEqual <int>(
                9,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4573,
                @"[In SyncKey(FolderCreate, FolderDelete, and FolderUpdate)] The server MUST return a Status element (section 2.2.3.162.4) value of 9 if the value of the SyncKey element does not match the value of the synchronization key on the server.");
        }
        public void MSASCMD_S02_TC02_FolderCreate_Fail()
        {
            // Call method FolderCreate to create a new folder as a child folder of the specified parent folder without DisplayName element value.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, string.Empty, "0");

            Site.Assert.IsNotNull(folderCreateResponse.ResponseData.Status, "The Status element should be return.");

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

            // If the FolderCreate command request fails, server returns a null ServerId.
            Site.CaptureRequirementIfIsNull(
                folderCreateResponse.ResponseData.ServerId,
                3904,
                @"[In ServerId(FolderCreate)] the element MUST NOT be returned if the FolderCreate command request fails.");

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

            // If the FolderCreate command request fails, server returns a null SyncKey.
            Site.CaptureRequirementIfIsNull(
                folderCreateResponse.ResponseData.SyncKey,
                4570,
                @"[In SyncKey(FolderCreate, FolderDelete, and FolderUpdate)] If the FolderCreate command [, FolderDelete command, or FolderUpdate command] is not successful, the server MUST NOT return a SyncKey element.");
        }
        public void MSASCMD_S02_TC03_FolderCreate_Status2()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the mailbox Root folder.
            string folderName = Common.GenerateResourceName(Site, "FolderCreate", 1);
            FolderCreateRequest  folderCreateRequest  = Common.CreateFolderCreateRequest(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, folderName, "0");
            FolderCreateResponse folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "If the FolderCreate command executes successfully, the Status in response should be 1.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderCreate to create another new folder with same name as a child folder of the mailbox Root folder.
            folderCreateRequest  = Common.CreateFolderCreateRequest(folderCreateResponse.ResponseData.SyncKey, (byte)FolderType.UserCreatedMail, folderName, "0");
            folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4013
            Site.CaptureRequirementIfAreEqual <int>(
                2,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4013,
                @"[In Status(FolderCreate)] [When the scope is Item], [the cause of the status value 2 is] The parent folder already contains a folder that has this name.");
            #endregion
        }
        public void MSASCMD_S03_TC04_FolderDelete_Status9()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderDelete"), "0");
            Site.Assert.AreEqual <int>(
                1,
                int.Parse(folderCreateResponse.ResponseData.Status),
                "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            #endregion

            #region Call method FolderDelete to delete a folder from the server, and set SyncKey value to an empty string.
            FolderDeleteRequest  folderDeleteRequest  = Common.CreateFolderDeleteRequest(string.Empty, folderCreateResponse.ResponseData.ServerId);
            FolderDeleteResponse folderDeleteResponse = this.CMDAdapter.FolderDelete(folderDeleteRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4060
            Site.CaptureRequirementIfAreEqual <int>(
                9,
                int.Parse(folderDeleteResponse.ResponseData.Status),
                4060,
                @"[In Status(FolderDelete)] [When the scope is Global], [the cause of the status value 9 is] The client sent a malformed or mismatched synchronization key [, or the synchronization state is corrupted on the server].");
            #endregion

            #region Call method FolderDelete to delete the created folder from the server.
            folderDeleteRequest  = Common.CreateFolderDeleteRequest(folderCreateResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId);
            folderDeleteResponse = this.CMDAdapter.FolderDelete(folderDeleteRequest);
            Site.Assert.AreEqual <int>(1, int.Parse(folderDeleteResponse.ResponseData.Status), "The created Folder should be deleted.");
            #endregion
        }
        public void MSASCMD_S03_TC05_FolderDelete_Status10()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderDelete"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "If the FolderCreate command creates a folder successfully, server should return a status code 1.");
            #endregion

            #region Call method FolderDelete without folder SyncKey to delete a folder from the server.
            FolderDeleteRequest  folderDeleteRequest  = Common.CreateFolderDeleteRequest(null, folderCreateResponse.ResponseData.ServerId);
            FolderDeleteResponse folderDeleteResponse = this.CMDAdapter.FolderDelete(folderDeleteRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4063
            Site.CaptureRequirementIfAreEqual <int>(
                10,
                int.Parse(folderDeleteResponse.ResponseData.Status),
                4063,
                @"[In Status(FolderDelete)] [When the scope is Global], [the cause of the status value 10 is] The client sent a FolderCreate command request (section 2.2.2.3) that contains a semantic or syntactic error.");
            #endregion

            #region Call method FolderDelete to delete the created folder from the server.
            folderDeleteRequest  = Common.CreateFolderDeleteRequest(folderCreateResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId);
            folderDeleteResponse = this.CMDAdapter.FolderDelete(folderDeleteRequest);
            Site.Assert.AreEqual <int>(1, int.Parse(folderDeleteResponse.ResponseData.Status), "The server should return a status code 1 in the FolderDelete command response to indicate success.");
            #endregion
        }
        public void MSASCMD_S05_TC07_FolderUpdate_Moves()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the mailbox Root folder.
            string folderName = Common.GenerateResourceName(Site, "FolderCreate");
            FolderCreateRequest  folderCreateRequest  = Common.CreateFolderCreateRequest(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, folderName, "0");
            FolderCreateResponse folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);
            string folderServerId1 = folderCreateResponse.ResponseData.ServerId;
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderUpdate to move the new created folder from the mailbox Root folder to SentItems folder on the server.
            FolderUpdateRequest  folderUpdateRequest  = Common.CreateFolderUpdateRequest(folderCreateResponse.ResponseData.SyncKey, folderServerId1, folderName, ((byte)FolderType.SentItems).ToString());
            FolderUpdateResponse folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);
            Site.Assert.AreEqual <int>(1, int.Parse(folderUpdateResponse.ResponseData.Status), "Server should return status 1 to indicate FolderUpdate command success.");
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy.
            FolderSyncResponse folderSyncResponse = this.FolderSync();
            bool isFolderMoved = false;
            foreach (FolderSyncChangesAdd add in folderSyncResponse.ResponseData.Changes.Add)
            {
                if ((add.ServerId == folderServerId1) && (add.ParentId == ((byte)FolderType.SentItems).ToString()))
                {
                    isFolderMoved = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R139
            Site.CaptureRequirementIfIsTrue(
                isFolderMoved,
                139,
                @"[In FolderUpdate] The FolderUpdate command moves a folder from one location to another on the server.");

            // Call method FolderCreate to create another new folder which its name is same with above step as a child folder of the mailbox Root folder.
            folderCreateRequest  = Common.CreateFolderCreateRequest(folderSyncResponse.ResponseData.SyncKey, (byte)FolderType.UserCreatedMail, folderName, "0");
            folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);

            // Call method FolderUpdate to move the newest created folder in mailbox Root folder from mailbox Root folder to SentItems folder on the server.
            folderUpdateRequest  = Common.CreateFolderUpdateRequest(folderCreateResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId, folderName, ((byte)FolderType.SentItems).ToString());
            folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5438
            Site.CaptureRequirementIfAreEqual <int>(
                2,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                5438,
                @"[In Status(FolderUpdate)] [When the scope is Item], [the cause of the status value 2 is] A folder with that name already exists [or the specified folder is a special folder, such as the Inbox, Outbox, Contacts, or Drafts folders. Special folders cannot be updated].");
            #endregion
        }
        /// <summary>
        /// Creates a new folder as a child folder of the specified parent folder.
        /// </summary>
        /// <param name="request">A FolderCreateRequest object that contains the request information.</param>
        /// <returns>FolderCreate command response</returns>
        public FolderCreateResponse FolderCreate(FolderCreateRequest request)
        {
            FolderCreateResponse response = this.activeSyncClient.FolderCreate(request);

            this.VerifyTransportRequirements();
            this.VerifyWBXMLCapture(CommandName.FolderCreate, response);
            this.VerifyFolderCreateCommand(response);
            return(response);
        }
        public void MSASCMD_S05_TC01_FolderUpdate_Success()
        {
            #region Call method FolderCreate command to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderUpdate to rename a folder.
            string updateFolderName = Common.GenerateResourceName(Site, "FolderUpdate");
            FolderUpdateRequest  folderUpdateRequest  = Common.CreateFolderUpdateRequest(folderCreateResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId, updateFolderName, "0");
            FolderUpdateResponse folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy.
            FolderSyncResponse folderSyncResponse = this.FolderSync();
            bool isFolderRenamed = false;
            foreach (FolderSyncChangesAdd add in folderSyncResponse.ResponseData.Changes.Add)
            {
                if ((add.DisplayName == updateFolderName) && (add.ServerId == folderCreateResponse.ResponseData.ServerId))
                {
                    isFolderRenamed = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R140
            Site.CaptureRequirementIfIsTrue(
                isFolderRenamed,
                140,
                @"[In FolderUpdate] The [FolderUpdate] command is also used to rename a folder.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4100
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                folderUpdateResponse.ResponseData.Status,
                4100,
                @"[In Status(FolderUpdate)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // IF folder has been updated successfully, the server must send a synchronization key to the client in a response.
            Site.CaptureRequirementIfIsNotNull(
                folderUpdateResponse.ResponseData.SyncKey,
                5784,
                @"[In SyncKey(FolderCreate, FolderDelete, and FolderUpdate)] After a successful [FolderCreate command (section 2.2.2.2), FolderDelete command (section 2.2.2.3), or] FolderUpdate command (section 2.2.2.5), the server MUST send a synchronization key to the client in a response.");
            #endregion
        }
示例#12
0
        public void MSASCMD_S11_TC05_Ping_Status7_Outdate()
        {
            #region Change a new user to call ActiveSync operation with a new DeviceID.
            this.CMDAdapter.SwitchUser(this.User3Information.UserName, this.User3Information.UserPassword, this.User3Information.UserDomain);

            // Record user that uses new DeviceID
            this.RecordDeviceInfoChanged();
            this.CMDAdapter.ChangeDeviceID("FirstDeviceID");
            #endregion

            #region Sync user folder changes
            this.FolderSync();
            #endregion

            #region Switch to new device and create one folder
            this.CMDAdapter.ChangeDeviceID("SecondDeviceID");
            string folderSynKey = this.GetFolderSyncKey();

            // Create one mail type folder
            string newFolderName = Guid.NewGuid().ToString().Replace("-", string.Empty);
            FolderCreateRequest  folderCreateRequest  = Common.CreateFolderCreateRequest(folderSynKey, 12, newFolderName, this.User1Information.InboxCollectionId);
            FolderCreateResponse folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);
            Site.Assert.AreEqual <int>(
                1,
                int.Parse(folderCreateResponse.ResponseData.Status),
                "After folder create success, server should return status 1");
            #endregion

            #region Switch back to old device and send one ping request
            this.CMDAdapter.ChangeDeviceID("FirstDeviceID");
            PingRequest  pingRequest  = CreatePingRequest(this.User1Information.InboxCollectionId, Request.PingFolderClass.Email);
            PingResponse pingResponse = this.CMDAdapter.Ping(pingRequest);
            #endregion

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4257
            Site.CaptureRequirementIfAreEqual <int>(
                7,
                int.Parse(pingResponse.ResponseData.Status),
                4257,
                @"[In Status(Ping)] [When the scope is Global], [the cause of the status value 7 is] The folder hierarchy is out of date.");

            #region Record new created folder collection ID.
            // Get new created folder collection ID
            FolderSyncRequest  folderSyncRequestForNewFolder  = Common.CreateFolderSyncRequest("0");
            FolderSyncResponse folderSyncResponseForNewFolder = this.CMDAdapter.FolderSync(folderSyncRequestForNewFolder);

            // Gets the server ID for new folder after change DeviceID.
            string serverId = TestSuiteBase.GetCollectionId(folderSyncResponseForNewFolder, newFolderName);
            TestSuiteBase.RecordCaseRelativeFolders(this.User3Information, serverId);
            #endregion
        }
        public void MSASCMD_S05_TC06_FolderUpdate_Status10()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderUpdate to rename the created folder without SyncKey element.
            FolderUpdateRequest  folderUpdateRequest  = Common.CreateFolderUpdateRequest(null, folderCreateResponse.ResponseData.ServerId, Common.GenerateResourceName(Site, "FolderUpdate"), "0");
            FolderUpdateResponse folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);

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

            // The server should return a status code 10 in the FolderUpdate command response to indicate the client sent FolderUpdate request contains a semantic error.
            // Verify MS-ASCMD requirement: MS-ASCMD_R3102
            Site.CaptureRequirementIfAreEqual <int>(
                10,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                3102,
                @"[In FolderUpdate] Including the Status element in a FolderUpdate request results in a Status element value of 10 being returned in the response.");

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

            // The server should return a status code 10 in the FolderUpdate command response to indicate the client sent FolderUpdate request contains a semantic error.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4123
            Site.CaptureRequirementIfAreEqual <int>(
                10,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                4123,
                @"[In Status(FolderUpdate)] [When the scope is Global], [the cause of the status value 10 is] The client sent a FolderUpdate command request that contains a semantic error.");

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

            // The server should return a status code 10 in the FolderUpdate command response to indicate the client sent FolderUpdate request does not contain SyncKey element.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4568
            Site.CaptureRequirementIfAreEqual <int>(
                10,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                4568,
                @"[In SyncKey(FolderCreate, FolderDelete, and FolderUpdate)] The server returns a Status element (section 2.2.3.162.5) value of 10 if the SyncKey element is not included in a FolderUpdate command request.");
            #endregion
        }
        public void MSASCMD_S04_TC03_FolderSync_Changed()
        {
            #region Change a new DeviceID and call FolderSync command.
            this.CMDAdapter.ChangeDeviceID(Common.GetConfigurationPropertyValue("DeviceID", this.Site));
            FolderSyncResponse folderSyncResponseForDefaultDeviceID = this.FolderSync();
            #endregion

            #region Change a new DeviceID and call FolderSync command.
            this.CMDAdapter.ChangeDeviceID("NewDeviceID");
            this.RecordDeviceInfoChanged();
            string             folderName = Common.GenerateResourceName(Site, "FolderSync");
            FolderSyncResponse folderSyncResponseForNewDeviceID = this.FolderSync();
            #endregion

            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(folderSyncResponseForNewDeviceID.ResponseData.SyncKey, (byte)FolderType.UserCreatedMail, folderName, "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Change the DeviceId back and call method FolderSync to synchronize the collection hierarchy.
            this.CMDAdapter.ChangeDeviceID(Common.GetConfigurationPropertyValue("DeviceID", this.Site));
            FolderSyncRequest  folderSyncRequest  = Common.CreateFolderSyncRequest(folderSyncResponseForNewDeviceID.ResponseData.SyncKey);
            FolderSyncResponse folderSyncResponse = this.CMDAdapter.FolderSync(folderSyncRequest);
            foreach (Response.FolderSyncChangesAdd add in folderSyncResponse.ResponseData.Changes.Add)
            {
                if (add.DisplayName == folderName)
                {
                    this.User1Information.UserCreatedFolders.Clear();
                    TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, add.ServerId);
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5024
            Site.CaptureRequirementIfAreEqual <uint>(
                (uint)1,
                folderSyncResponse.ResponseData.Changes.Count,
                5024,
                @"[In Synchronizing a Folder Hierarchy] [FolderSync sequence for folder hierarchy synchronization, order 2:] If any changes have occurred on the server, the new, deleted, or changed folders are returned to the client.");
            #endregion
        }
        public void MSASCMD_S02_TC06_FolderCreate_Status10()
        {
            // Call method FolderCreate to create a new folder as a child folder of the specified parent folder without folder SyncKey.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(null, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");

            Site.Assert.AreEqual <int>(10, int.Parse(folderCreateResponse.ResponseData.Status), "If the request contains a semantic error, the status should be equal to 10.");
            folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.Inbox, Common.GenerateResourceName(this.Site, "FolderCreate"), "0");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4035
            Site.CaptureRequirementIfAreEqual <int>(
                10,
                int.Parse(folderCreateResponse.ResponseData.Status),
                4035,
                @"[In Status(FolderCreate)] [When the scope is Global], [the cause of the status value 10 is] The client sent a FolderCreate command request (section 2.2.2.2) that contains a semantic error, or the client attempted to create a default folder, such as the Inbox folder, Outbox folder, or Contacts folder.");
        }
        public void MSASCMD_S02_TC08_FolderCreate_RecipientInformationCache_Status3()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The recipient information cache 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.");

            // Set the specified parent folder is the recipient information cache
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.RecipientInformationCache, Common.GenerateResourceName(Site, "FolderCreate"), User1Information.InboxCollectionId);

            Site.Assert.AreEqual <int>(3, int.Parse(folderCreateResponse.ResponseData.Status), "The status should be equal to 3 when the FolderCreate is used to create a recipient information cache.");

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

            // Since server return status 3, the FolderCreate command cannot be used to update a recipient information cache.
            // Verify MS-ASCMD requirement: MS-ASCMD_R81
            Site.CaptureRequirement(
                81,
                @"[In FolderCreate] The FolderCreate command cannot be used to create a recipient information cache [or a subfolder of a recipient information cache].");
        }
        public void MSASCMD_S05_TC05_FolderUpdate_Status9()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderUpdate to rename a folder with invalid synchronization key.
            FolderUpdateRequest  folderUpdateRequest  = Common.CreateFolderUpdateRequest("InvalidSyncKey", folderCreateResponse.ResponseData.ServerId, Common.GenerateResourceName(Site, "FolderUpdate"), "0");
            FolderUpdateResponse folderUpdateResponse = this.CMDAdapter.FolderUpdate(folderUpdateRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4120
            Site.CaptureRequirementIfAreEqual <int>(
                9,
                int.Parse(folderUpdateResponse.ResponseData.Status),
                4120,
                @"[In Status(FolderUpdate)] [When the scope is Global], [the cause of the status value 9 is] The client sent a malformed or mismatched synchronization key, or the synchronization state is corrupted on the server.");
            #endregion
        }
        public void MSASHTTP_S01_TC11_CommandCode_FolderRelatedCommands()
        {
            string folderNameToCreate = Common.GenerateResourceName(this.Site, "CreatedFolder");
            string folderNameToUpdate = Common.GenerateResourceName(this.Site, "UpdatedFolder");

            #region Call FolderSync command to synchronize the folder hierarchy.
            FolderSyncResponse folderSyncResponse = this.CallFolderSyncCommand();
            #endregion

            #region Call FolderCreate command to create a sub folder under Inbox folder.
            FolderCreateResponse folderCreateResponse = this.CallFolderCreateCommand(folderSyncResponse.ResponseData.SyncKey, folderNameToCreate, Common.GetDefaultFolderServerId(folderSyncResponse, FolderType.Inbox, Site));
            #endregion

            #region Call FolderSync command to synchronize the folder hierarchy.
            folderSyncResponse = this.CallFolderSyncCommand();

            // Get the created folder name using the ServerId returned in FolderSync response.
            string createdFolderName = this.GetFolderFromFolderSyncResponse(folderSyncResponse, folderCreateResponse.ResponseData.ServerId, "DisplayName");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R493
            // The created folder could be got in FolderSync response, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                folderNameToCreate,
                createdFolderName,
                493,
                @"[In Command Codes] [Command] FolderCreate creates an e-mail, [calendar, or contacts folder] on the server.");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R491
            // R493 is captured, so this requirement can be captured directly.
            Site.CaptureRequirement(
                491,
                @"[In Command Codes] [Command] FolderSync synchronizes the folder hierarchy.");

            // Call the Sync command with latest SyncKey without change in folder.
            SyncStore syncResponse = this.CallSyncCommand(folderCreateResponse.ResponseData.ServerId);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R482
            // If response is not in xml, this requirement can be captured.
            Site.CaptureRequirementIfIsNull(
                syncResponse.SyncKey,
                482,
                @"[In Response Body] Three commands have no XML body in certain contexts: [GetAttachment,] Sync [, and Ping].");
            #endregion

            #region Call FolderUpdate command to update the name of the created folder to a new folder name and move the created folder to SentItems folder.
            this.CallFolderUpdateCommand(folderSyncResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId, folderNameToUpdate, Common.GetDefaultFolderServerId(folderSyncResponse, FolderType.SentItems, this.Site));
            #endregion

            #region Call FolderSync command to synchronize the folder hierarchy.
            folderSyncResponse = this.CallFolderSyncCommand();

            // Get the updated folder name using the ServerId returned in FolderSync response.
            string updatedFolderName = this.GetFolderFromFolderSyncResponse(folderSyncResponse, folderCreateResponse.ResponseData.ServerId, "DisplayName");
            string updatedParentId   = this.GetFolderFromFolderSyncResponse(folderSyncResponse, folderCreateResponse.ResponseData.ServerId, "ParentId");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R431
            // The folder name is updated to the specified name, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                folderNameToUpdate,
                updatedFolderName,
                431,
                @"[In Command Codes] [Command] FolderUpdate is used to rename folders.");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R68
            // The folder has been moved to the new created folder, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                Common.GetDefaultFolderServerId(folderSyncResponse, FolderType.SentItems, this.Site),
                updatedParentId,
                68,
                @"[In Command Codes] [Command] FolderUpdate moves a folder from one location to another on the server.");
            #endregion

            #region Call FolderDelete to delete the folder from the server.
            this.CallFolderDeleteCommand(folderSyncResponse.ResponseData.SyncKey, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call FolderSync command to synchronize the folder hierarchy.
            folderSyncResponse = this.CallFolderSyncCommand();

            // Get the created folder name using the ServerId returned in FolderSync response.
            updatedFolderName = this.GetFolderFromFolderSyncResponse(folderSyncResponse, folderCreateResponse.ResponseData.ServerId, "DisplayName");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R496
            // The folder with the specified ServerId could not be got, so this requirement can be captured.
            Site.CaptureRequirementIfIsNull(
                updatedFolderName,
                496,
                @"[In Command Codes] [Command] FolderDelete deletes a folder from the server.");
            #endregion
        }
示例#19
0
        /// <summary>
        /// This method is used to verify the FolderCreate response related requirements.
        /// </summary>
        /// <param name="folderCreateResponse">FolderCreate command response.</param>
        private void VerifyFolderCreateCommand(FolderCreateResponse folderCreateResponse)
        {
            Site.Assert.IsTrue(this.activeSyncClient.ValidationResult, "The schema validation result should be true.");
            Site.Assert.IsNotNull(folderCreateResponse.ResponseData, "The FolderCreate element should not be null.");

            #region Capture code for FolderCreate
            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3084");

            // If the schema validation result is true and FolderCreate is not null, this requirement can be verified.
            Site.CaptureRequirement(
                3084,
                @"[In FolderCreate] The FolderCreate element is a required element in FolderCreate command requests and FolderCreate command responses that identifies the body of the HTTP POST as containing a FolderCreate command (section 2.2.2.2).");

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

            // If the schema validation result is true and FolderCreate is not null, this requirement can be verified.
            Site.CaptureRequirement(
                1683,
                @"[In FolderCreate] None [Element FolderCreate in FolderCreate command response has no parent element.]");

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

            // If the schema validation result is true and FolderCreate is not null, this requirement can be verified.
            Site.CaptureRequirement(
                1684,
                @"[In FolderCreate] Element FolderCreate in FolderCreate command response, the child elements are SyncKey, ServerId (section 2.2.3.151.1), Status (section 2.2.3.162.2).");

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

            // If the schema validation result is true and FolderCreate is not null, this requirement can be verified.
            Site.CaptureRequirement(
                1685,
                @"[In FolderCreate] Element FolderCreate in FolderCreate command response, the data type is container.");

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

            // If the schema validation result is true and FolderCreate is not null, this requirement can be verified.
            Site.CaptureRequirement(
                1686,
                @"[In FolderCreate] Element FolderCreate in FolderCreate command response, the number allowed is 1…1 (required).");

            this.VerifyContainerDataType();
            #endregion

            #region Capture code for SyncKey(FolderCreate)
            if (folderCreateResponse.ResponseData.SyncKey != null)
            {
                // Add the debug information.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2803");

                // If the schema validation result is true and SyncKey(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2803,
                    @"[In SyncKey(FolderCreate)] Element SyncKey in FolderCreate command response, the parent element is FolderCreate.");

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

                // If the schema validation result is true and SyncKey(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2804,
                    @"[In SyncKey(FolderCreate] None [Element SyncKey in FolderCreate command response has no child element.]");

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

                // If the schema validation result is true and SyncKey(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2805,
                    @"[In SyncKey(FolderCreate)] Element SyncKey in FolderCreate command response, the data type is string.");

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

                // If the schema validation result is true and SyncKey(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2806,
                    @"[In SyncKey(FolderCreate)] Element SyncKey in FolderCreate command response, the number allowed is 0...1 (optional).");

                this.VerifyStringDataType();
            }
            #endregion

            #region Capture code for ServerId(FolderCreate)
            if (folderCreateResponse.ResponseData.ServerId != null)
            {
                // Add the debug information.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2569");

                // If the schema validation result is true and ServerId(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2569,
                    @"[In ServerId(FolderCreate)] Element ServerId in FolderCreate command response,the parent element is FolderCreate (section 2.2.3.67).");

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

                // If the schema validation result is true and ServerId(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2570,
                    @"[In ServerId(FolderCreate)] None [Element ServerId in FolderCreate command response has no child element.]");

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

                // If the schema validation result is true and ServerId(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2571,
                    @"[In ServerId(FolderCreate)] Element ServerId in FolderCreate command response, the data type is string ([MS-ASDTYPE] section 2.7).");

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

                // If the schema validation result is true and ServerId(FolderCreate) is not null, this requirement can be verified.
                Site.CaptureRequirement(
                    2572,
                    @"[In ServerId(FolderCreate)] Element ServerId in FolderCreate command response, the number allowed is 0...1 (optional).");

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

                // Verify MS-ASCMD requirement: MS-ASCMD_R5872
                Site.CaptureRequirementIfIsTrue(
                    folderCreateResponse.ResponseData.ServerId.Length <= 64,
                    5872,
                    @"[In ServerId(FolderCreate)] The ServerId element value is not larger than 64 characters in length.");

                this.VerifyStringDataType();
            }
            #endregion

            #region Capture code for Status(FolderCreate)
            // Add the debug information.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2695");

            // If the schema validation result is true, this requirement can be verified.
            Site.CaptureRequirement(
                2695,
                @"[In Status(FolderCreate)] Element Status in FolderCreate command response, the parent element is FolderCreate (section 2.2.3.67).");

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

            // If the schema validation result is true, this requirement can be verified.
            Site.CaptureRequirement(
                2696,
                @"[In Status(FolderCreate)] None [Element Status in FolderCreate command response has no child element.]");

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

            // If the schema validation result is true, this requirement can be verified.
            Site.CaptureRequirement(
                2697,
                @"[In Status(FolderCreate)] Element Status in FolderCreate command response, the data type is unsignedByte ([MS-ASDTYPE] section 2.8).");

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

            // If the schema validation result is true, this requirement can be verified.
            Site.CaptureRequirement(
                2698,
                @"[In Status(FolderCreate)] Element Status in FolderCreate command response, the number allowed is 1…1 (required).");

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

            // If the schema validation result is true, this requirement can be verified.
            Site.CaptureRequirement(
                4005,
                @"[In Status(FolderCreate)] The Status element is a required child element of the FolderCreate element in FolderCreate command responses that indicates the success or failure of a FolderCreate command request (section 2.2.2.2).");

            Common.VerifyActualValues("Status(FolderCreate)", AdapterHelper.ValidStatus(new string[] { "1", "2", "3", "5", "6", "9", "10", "11", "12" }), folderCreateResponse.ResponseData.Status.ToString(), this.Site);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4008
            // If above Common.VerifyActualValues method is not failed, this requirement can be verified.
            Site.CaptureRequirement(
                4008,
                @"[In Status(FolderCreate)] The following table lists the status codes [1,2,3,5,6,9,10,11,12] for the FolderCreate command (section 2.2.2.2). For information about the scope of the status value and for status values common to all ActiveSync commands, see section 2.2.4.");

            this.VerifyIntegerDataType();
            #endregion
        }
        /// <summary>
        /// Call FolderCreate command to create a sub folder under the specific parent folder.
        /// </summary>
        /// <param name="syncKey">The SyncKey of the latest sync.</param>
        /// <param name="createdFolder">The folder name of the sub folder to create.</param>
        /// <param name="parentFolder">The ServerId of the parent folder.</param>
        /// <returns>The response of FolderCreate command.</returns>
        protected FolderCreateResponse CallFolderCreateCommand(string syncKey, string createdFolder, string parentFolder)
        {
            FolderCreateRequest folderCreateRequest = Common.CreateFolderCreateRequest(syncKey, (byte)12, createdFolder, parentFolder);
            SendStringResponse folderCreateResponseString = this.HTTPAdapter.HTTPPOST(CommandName.FolderCreate, null, folderCreateRequest.GetRequestDataSerializedXML());

            // Check the command is executed successfully.
            this.CheckResponseStatus(folderCreateResponseString.ResponseDataXML);

            FolderCreateResponse folderCreateResponse = new FolderCreateResponse
            {
                ResponseDataXML = folderCreateResponseString.ResponseDataXML
            };
            folderCreateResponse.DeserializeResponseData();

            return folderCreateResponse;
        }
        public void MSASHTTP_S01_TC12_CommandCode_ItemRelatedCommands()
        {
            #region Call ConfigureRequestPrefixFields to change the query value type to Base64.
            IDictionary <HTTPPOSTRequestPrefixField, string> requestPrefix = new Dictionary <HTTPPOSTRequestPrefixField, string>();
            requestPrefix.Add(HTTPPOSTRequestPrefixField.QueryValueType, QueryValueType.Base64.ToString());
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion

            #region Call SendMail command to send email to User2.
            string sendMailSubject       = Common.GenerateResourceName(Site, "SendMail");
            string folderNameToCreate    = Common.GenerateResourceName(Site, "CreatedFolder");
            string userOneMailboxAddress = Common.GetMailAddress(this.UserOneInformation.UserName, this.UserOneInformation.UserDomain);
            string userTwoMailboxAddress = Common.GetMailAddress(this.UserTwoInformation.UserName, this.UserTwoInformation.UserDomain);

            // Call SendMail command to send email to User2.
            this.CallSendMailCommand(userOneMailboxAddress, userTwoMailboxAddress, sendMailSubject, null);
            #endregion

            #region Call Ping command for changes that would require the client to resynchronize.
            // Switch the user to User2 and synchronize the collection hierarchy.
            this.SwitchUser(this.UserTwoInformation, true);

            // Call FolderSync command to synchronize the collection hierarchy.
            FolderSyncResponse folderSyncResponse = this.CallFolderSyncCommand();

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R428
            // The received email could not be got by FolderSync command, so this requirement can be captured.
            Site.CaptureRequirementIfIsFalse(
                folderSyncResponse.ResponseDataXML.Contains(sendMailSubject),
                428,
                @"[In Command Codes] But [command] FolderSync does not synchronize the items in the folders.");

            // Call Ping command for changes of Inbox folder.
            PingResponse pingResponse = this.CallPingCommand(this.UserTwoInformation.InboxCollectionId);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R504
            // The Status of the Ping command is 2 which means this folder needs to be synced, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                "2",
                pingResponse.ResponseData.Status.ToString(),
                504,
                @"[In Command Codes] [Command] Ping requests that the server monitor specified folders for changes that would require the client to resynchronize.");
            #endregion

            #region Get the ServerId of the received email.
            // Call Sync command to get the ServerId of the received email.
            string receivedItemServerId = this.LoopToSyncItem(this.UserTwoInformation.InboxCollectionId, sendMailSubject, true);
            #endregion

            #region Call FolderCreate command to create a sub folder under Inbox folder.
            FolderCreateResponse folderCreateResponse = this.CallFolderCreateCommand(folderSyncResponse.ResponseData.SyncKey, folderNameToCreate, this.UserTwoInformation.InboxCollectionId);

            // Get the ServerId of the created folder.
            string createdFolder = folderCreateResponse.ResponseData.ServerId;
            #endregion

            #region Move the received email from Inbox folder to the created folder.
            this.CallMoveItemsCommand(receivedItemServerId, this.UserTwoInformation.InboxCollectionId, createdFolder);
            #endregion

            #region Get the moved email in the created folder.
            // Call Sync command to get the received email.
            receivedItemServerId = this.LoopToSyncItem(createdFolder, sendMailSubject, true);

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R499
            // The moved email could be got in the new created folder, so this requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                receivedItemServerId,
                499,
                @"[In Command Codes] [Command] MoveItems moves items from one folder to another.");
            #endregion

            #region Call ItemOperation command to fetch the email in Sent Items folder with AcceptMultiPart command parameter.
            SendStringResponse itemOperationResponse = this.CallItemOperationsCommand(createdFolder, receivedItemServerId, true);
            Site.Assert.IsNotNull(itemOperationResponse.Headers["Content-Type"], "The Content-Type header should not be null.");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R94
            // The content is in multipart, so this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <string>(
                "application/vnd.ms-sync.multipart",
                itemOperationResponse.Headers["Content-Type"],
                94,
                @"[In Command Parameters] [When flag] AcceptMultiPart [value is] 0x02, [the meaning is] setting this flag [AcceptMultiPart] to instruct the server to return the requested item in multipart format.");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R95
            // R94 can be captured, so this requirement can be captured directly.
            Site.CaptureRequirement(
                95,
                @"[In Command Parameters] [When flag] AcceptMultiPart [value is] 0x02, [it is] valid for ItemOperations.");

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

            // Verify MS-ASHTTP requirement: MS-ASHTTP_R534
            // R94 can be captured, so this requirement can be captured directly.
            Site.CaptureRequirement(
                534,
                @"[In Command Parameters] [Parameter] Options [ is used by] ItemOperations.");
            #endregion

            #region Call FolderDelete to delete a folder from the server.
            this.CallFolderDeleteCommand(folderCreateResponse.ResponseData.SyncKey, createdFolder);
            #endregion

            #region Reset the query value type and user credential.
            requestPrefix[HTTPPOSTRequestPrefixField.QueryValueType] = Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            this.SwitchUser(this.UserOneInformation, false);
            #endregion
        }
        public void MSASCMD_S02_TC01_FolderCreate_Success()
        {
            #region Call method FolderCreate to create a new folder as a child folder of the specified parent folder.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "If the FolderCreate command executes successfully, the Status in response should be 1.");

            // Record created folder collectionID.
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy.
            FolderSyncResponse folderSyncResponse = this.FolderSync();
            bool folderAddSuccess = false;
            foreach (FolderSyncChangesAdd add in folderSyncResponse.ResponseData.Changes.Add)
            {
                if (add.ServerId == folderCreateResponse.ResponseData.ServerId)
                {
                    folderAddSuccess = true;
                    break;
                }
            }
            #endregion

            #region Capture FolderCreate command success related requirements
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4011");

            // If the serverId of Add element equal with the serverId specified in the response of FolderCreate command, it indicates the FolderCreate command completed successfully.
            // Verify MS-ASCMD requirement: MS-ASCMD_R4011
            Site.CaptureRequirementIfIsTrue(
                folderAddSuccess,
                4011,
                @"[In Status(FolderCreate)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // If the serverId of Add element equal with the serverId specified in the response of FolderCreate command, it indicates the FolderCreate command completed successfully.
            // Verify MS-ASCMD requirement: MS-ASCMD_R79
            Site.CaptureRequirementIfIsTrue(
                folderAddSuccess,
                79,
                @"[In FolderCreate] The FolderCreate command creates a new folder as a child folder of the specified parent folder.");

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

            // Folder has been created successfully, server returns a non-null ServerId.
            Site.CaptureRequirementIfIsNotNull(
                folderCreateResponse.ResponseData.ServerId,
                3903,
                @"[In ServerId(FolderCreate)] The ServerId element MUST be returned if the FolderCreate command request was successful.");

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

            // Folder has been created successfully, server must send a synchronization key to the client in a response.
            Site.CaptureRequirementIfIsNotNull(
                folderCreateResponse.ResponseData.SyncKey,
                4569,
                @"[In SyncKey(FolderCreate, FolderDelete, and FolderUpdate)] After a successful FolderCreate command (section 2.2.2.2) [, FolderDelete command (section 2.2.2.3), or FolderUpdate command (section 2.2.2.5)], the server MUST send a synchronization key to the client in a response.");
            #endregion
        }
        public void MSASCMD_S22_TC01_GetHierarchySuccess()
        {
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetHierarchy command is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetHierarchy command is not supported when the MS-ASProtocolVersion header is set to 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetHierarchy command is not supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("16.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetHierarchy command is not supported when the MS-ASProtocolVersion header is set to 16.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region The client calls FolderCreate command to create a new folder as a child folder of the specified parent folder, then server returns ServerId for FolderCreate command.
            FolderCreateResponse folderCreateResponse = this.GetFolderCreateResponse(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderSync"), "0");
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderCreate command response to indicate success.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy.
            FolderSyncResponse folderSyncResponse = this.FolderSync();
            Site.Assert.AreEqual <int>(1, int.Parse(folderCreateResponse.ResponseData.Status), "The server should return a status code 1 in the FolderSync command response to indicate success.");
            string sentItemFolderCollectionId   = string.Empty;
            string deleteItemFolderCollectionId = string.Empty;

            foreach (Response.FolderSyncChangesAdd folderAdd in folderSyncResponse.ResponseData.Changes.Add)
            {
                if (string.Compare(folderAdd.DisplayName, "Sent Items", true) == 0)
                {
                    sentItemFolderCollectionId = folderAdd.ServerId;
                }

                if (string.Compare(folderAdd.DisplayName, "Deleted Items", true) == 0)
                {
                    deleteItemFolderCollectionId = folderAdd.ServerId;
                }
            }
            #endregion

            #region Call method GetHierarchy to get the list of email folders from the server.
            GetHierarchyResponse getHierarchyResponse = this.CMDAdapter.GetHierarchy();

            bool isVerifiedR7505 = false;
            bool isVerifiedR7507 = false;
            foreach (Response.FoldersFolder folder in getHierarchyResponse.ResponseData.Folder)
            {
                if (folder.DisplayName.Equals("Sent Items"))
                {
                    isVerifiedR7505 = true;
                }

                if (folder.DisplayName.Equals("Deleted Items"))
                {
                    isVerifiedR7507 = true;
                }
            }

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR7505,
                7505,
                @"[In GetHierarchy] The client can use the GetHierarchy command to obtain the collection ID of a folder, such as Sent Items folder [or Deleted Items folder], that cannot be deleted.");

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR7507,
                7507,
                @"[In GetHierarchy] The client can use the GetHierarchy command to obtain the collection ID of a folder, such as [Sent Items folder or] Deleted Items folder, that cannot be deleted.");

            // If R6030 have been verfied and sentItemFolderCollectionId is not null , then the client can obtain the collection ID of folder from ServerId element of previous FOlderSync
            this.Site.CaptureRequirementIfIsTrue(
                string.IsNullOrEmpty(sentItemFolderCollectionId) == false,
                6031,
                @"[In GetHierarchy] The collection ID is obtained from the ServerId element of a previous FolderSync [or FolderCreate] command.");

            bool isVerifiedR6032 = string.IsNullOrEmpty(folderCreateResponse.ResponseData.ServerId) == false;

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR6032,
                6032,
                @"[In GetHierarchy] The collection ID is obtained from the ServerId element of a previous [FolderSync or] FolderCreate command.");

            bool isVerifiedR6025 = false;

            foreach (Response.FoldersFolder folder in getHierarchyResponse.ResponseData.Folder)
            {
                if (!string.IsNullOrEmpty(folder.ParentId))
                {
                    isVerifiedR6025 = true;
                }
                else
                {
                    isVerifiedR6025 = false;
                    break;
                }
            }

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR6025,
                6025,
                @"[In GetHierarchy] Each folder's place within the folder hierarchy is indicated by its parent ID.");

            bool isVerifiedR6026 = false;
            foreach (Response.FoldersFolder folder in getHierarchyResponse.ResponseData.Folder)
            {
                // According Open Specification, if the type of the folder is not 1, 2, 3, 4, 5 and 6 then this folder is not a email folder.
                if (folder.Type == 1 || folder.Type == 2 || folder.Type == 3 || folder.Type == 4 || folder.Type == 5 || folder.Type == 6)
                {
                    isVerifiedR6026 = true;
                }
                else
                {
                    isVerifiedR6026 = false;
                }
            }

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR6026,
                6026,
                @"[In GetHierarchy] The list of folders returned by the GetHierarchy command includes only email folders.");

            // If above requirements have been verified, the R6024 will be verified.
            this.Site.CaptureRequirement(
                6024,
                @"[In GetHierarchy] The GetHierarchy command gets the list of email folders from the server.");
            #endregion
        }