Microsoft.Protocols.TestSuites.MS_OXCROPS.S02_FolderROPs.MSOXCROPS_S02_TC04_TestRopDeleteMessages C# (CSharp) Method

MSOXCROPS_S02_TC04_TestRopDeleteMessages() private method

private MSOXCROPS_S02_TC04_TestRopDeleteMessages ( ) : void
return void
        public void MSOXCROPS_S02_TC04_TestRopDeleteMessages()
        {
            this.CheckTransportIsSupported();

            this.cropsAdapter.RpcConnect(
                Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
                ConnectionType.PrivateMailboxServer,
                Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
                Common.GetConfigurationPropertyValue("Domain", this.Site),
                Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
                Common.GetConfigurationPropertyValue("PassWord", this.Site));

            // Log on to a private mailbox.
            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);

            // Step 1: Create a message in inbox folder.
            #region Create message

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;

            createMessageRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set OutputHandleIndex to 0x01, which specifies the location in the Server object handle table
            // where the handle for the output Server object will be stored.
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Set CodePageId to 0x0FFF, which specifies the code page for the message is the code page of Logon object.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            // Set FolderId to the 5th of logonResponse, which identifies the parent folder.
            createMessageRequest.FolderId = logonResponse.FolderIds[4];

            // Set AssociatedFlag to 0x00(FALSE), which specifies the message is not a folder associated information (FAI) message.
            createMessageRequest.AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: Begin to send the RopCreateMessage request.");

            // Send the RopCreateMessage request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            uint targetMessageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

            #endregion

            // Step 2: Save the created message.
            #region Save message

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set ResponseHandleIndex to 0x01, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;

            saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 2: Begin to send the RopSaveChangesMessage request.");

            // Send the RopSaveChangesMessage request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                saveChangesMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            ulong targetMessageId = saveChangesMessageResponse.MessageId;

            #endregion

            // Step 3: Open inbox folder.
            #region Open folder

            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
            openFolderRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set OutputHandleIndex to 0x01, which specifies the location in the Server object handle table
            // where the handle for the output Server object will be stored.
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Set FolderId to the 5th of logonResponse. This folder is to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopOpenFolder request.");

            // Send the RopOpenFolder request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openFolderRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            uint inboxFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 4: Delete message in inbox folder.
            #region RopDeleteMessages Response

            ulong[] messageIds = new ulong[1];
            messageIds[0] = targetMessageId;

            RopDeleteMessagesRequest deleteMessagesRequest;
            RopDeleteMessagesResponse deleteMessagesResponse;

            deleteMessagesRequest.RopId = (byte)RopId.RopDeleteMessages;
            deleteMessagesRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            deleteMessagesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set WantAsynchronous to 0x00(FALSE), which specifies the operation is to be executed synchronously.
            deleteMessagesRequest.WantAsynchronous = Convert.ToByte(TestSuiteBase.Zero);

            // Set NotifyNonRead to 0x00, which specifies the server does not generate a non-read receipt for the deleted messages.
            deleteMessagesRequest.NotifyNonRead = Convert.ToByte(TestSuiteBase.Zero);

            deleteMessagesRequest.MessageIdCount = (ushort)messageIds.Length;
            deleteMessagesRequest.MessageIds = messageIds;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 4: Begin to send the RopDeleteMessages request.");

            // Send the RopDeleteMessages request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                deleteMessagesRequest,
                inboxFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            deleteMessagesResponse = (RopDeleteMessagesResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                deleteMessagesResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 5: Create, save message and then open inbox folder.
            #region Create, save message and open inbox folder

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopCreateMessages request.");

            // Create a message in Inbox.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            targetMessageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopSaveMessages request.");

            // Save the created message.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                saveChangesMessageResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            targetMessageId = saveChangesMessageResponse.MessageId;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopOpenFolder request.");

            // Open Inbox.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openFolderRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");
            inboxFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 6: Send RopHardDeleteMessages request to the server and verify the success response.
            #region RopHardDeleteMessages Response

            messageIds[0] = targetMessageId;
            RopHardDeleteMessagesRequest hardDeleteMessagesRequest;

            hardDeleteMessagesRequest.RopId = (byte)RopId.RopHardDeleteMessages;
            hardDeleteMessagesRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            hardDeleteMessagesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set WantAsynchronous to 0x00(FALSE), which specifies the operation is to be executed synchronously.
            hardDeleteMessagesRequest.WantAsynchronous = Convert.ToByte(TestSuiteBase.Zero);

            // Set NotifyNonRead to 0x00(FALSE), which specifies the server does not generate a non-read receipt for the deleted messages.
            hardDeleteMessagesRequest.NotifyNonRead = Convert.ToByte(TestSuiteBase.Zero);

            hardDeleteMessagesRequest.MessageIdCount = (ushort)messageIds.Length;
            hardDeleteMessagesRequest.MessageIds = messageIds;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 6: Begin to send the RopHardDeleteMessages request.");

            // Send RopHardDeleteMessages request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                hardDeleteMessagesRequest,
                inboxFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                openFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 7: Release all resources associated with the Server object.
            #region RopRelease

            RopReleaseRequest releaseRequest;

            releaseRequest.RopId = (byte)RopId.RopRelease;
            releaseRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the input Server object is stored.
            releaseRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 7: Begin to send the RopRelease request.");

            // Send RopRelease request to the server to release all resources associated with the Server object.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                releaseRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }