Microsoft.Protocols.TestSuites.MS_OXCROPS.S04_MessageROPs.MSOXCROPS_S04_TC07_TestRopOpenEmbeddedMessage C# (CSharp) Method

MSOXCROPS_S04_TC07_TestRopOpenEmbeddedMessage() private method

private MSOXCROPS_S04_TC07_TestRopOpenEmbeddedMessage ( ) : void
return void
        public void MSOXCROPS_S04_TC07_TestRopOpenEmbeddedMessage()
        {
            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));

            // Step 1: Preparations-Create, modify recipients and save message, then create and save attachment on the message
            #region Create, modify recipients and save message, then create and save attachment on the message.

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

            // Create a message.
            #region Create a 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 specified the code page of Logon object will be used.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

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

            // Set AssociatedFlag to 0x00, which specified this 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 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

            // Modify recipients.
            #region Modify recipients

            RopModifyRecipientsRequest modifyRecipientsRequest;
            RopModifyRecipientsResponse modifyRecipientsResponse;

            modifyRecipientsRequest.RopId = (byte)RopId.RopModifyRecipients;
            modifyRecipientsRequest.LogonId = TestSuiteBase.LogonId;

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

            // Call CreateSampleRecipientColumnsAndRecipientRows method to create Recipient Rows and Recipient Columns.
            PropertyTag[] recipientColumns = null;
            ModifyRecipientRow[] recipientRows = null;
            this.CreateSampleRecipientColumnsAndRecipientRows(out recipientColumns, out recipientRows);

            // Set ColumnCount, which specifies the number of rows in the RecipientRows field.
            modifyRecipientsRequest.ColumnCount = (ushort)recipientColumns.Length;

            // Set RecipientColumns to that created above, which specifies the property values that can be included
            // for each recipient.
            modifyRecipientsRequest.RecipientColumns = recipientColumns;

            // Set RowCount, which specifies the number of rows in the RecipientRows field.
            modifyRecipientsRequest.RowCount = (ushort)recipientRows.Length;

            // Set RecipientRows to that created above, which is a list of ModifyRecipientRow structures.
            modifyRecipientsRequest.RecipientRows = recipientRows;

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

            // Send the RopModifyRecipients request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                modifyRecipientsRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            modifyRecipientsResponse = (RopModifyRecipientsResponse)response;

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

            #endregion

            // Save message.
            #region Save message

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            // Set RopId to 0x0C, which specifies the type of ROP is RopSaveChangesMessage.
            saveChangesMessageRequest.RopId = 0x0C;

            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 that is referenced
            // in the response.
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;

            saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 1: 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)");

            #endregion

            // Create attachment.
            #region Create attachment

            RopCreateAttachmentRequest createAttachmentRequest;
            RopCreateAttachmentResponse createAttachmentResponse;

            createAttachmentRequest.RopId = (byte)RopId.RopCreateAttachment;
            createAttachmentRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
            createAttachmentRequest.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.
            createAttachmentRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            // Send the RopCreateAttachment request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createAttachmentRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createAttachmentResponse = (RopCreateAttachmentResponse)response;

            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createAttachmentResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint attachmentHandle = responseSOHs[0][createAttachmentResponse.OutputHandleIndex];

            #endregion

            // Save attachment.
            #region Save attachment

            RopSaveChangesAttachmentRequest saveChangesAttachmentRequest;
            RopSaveChangesAttachmentResponse saveChangesAttachmentReponse;

            saveChangesAttachmentRequest.RopId = (byte)RopId.RopSaveChangesAttachment;
            saveChangesAttachmentRequest.LogonId = TestSuiteBase.LogonId;

            // Set ResponseHandleIndex to 0x01, which specifies the location in the Server object handle table that is referenced
            // in the response.
            saveChangesAttachmentRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;

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

            saveChangesAttachmentRequest.SaveFlags = (byte)SaveFlags.ForceSave;

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

            // Send the RopSaveChangesAttachment request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesAttachmentRequest,
                attachmentHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            saveChangesAttachmentReponse = (RopSaveChangesAttachmentResponse)response;

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

            #endregion

            #endregion

            // Step 2: Send the RopOpenEmbeddedMessage request and verify the success response.
            #region RopOpenEmbeddedMessage success response

            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest;
            RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse;

            openEmbeddedMessageRequest.RopId = (byte)RopId.RopOpenEmbeddedMessage;
            openEmbeddedMessageRequest.LogonId = TestSuiteBase.LogonId;

            // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table where the handle for the input Server object is stored.
            openEmbeddedMessageRequest.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.
            openEmbeddedMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Set CodePageId to 0x0FFF, which specified the code page of Logon object will be used.
            openEmbeddedMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            openEmbeddedMessageRequest.OpenModeFlags = (byte)EmbeddedMessageOpenModeFlags.Create;

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

            // Send the RopOpenEmbeddedMessage request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openEmbeddedMessageRequest,
                attachmentHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)response;

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

            #endregion

            // Step 3: Send the RopOpenEmbeddedMessage request and verify the failure response.
            #region RopOpenEmbeddedMessage failure response

            // Set InputHandleIndex to 0x01, which is an invalid index and will lead to a failure response.
            openEmbeddedMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            // Send the RopOpenEmbeddedMessage request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openEmbeddedMessageRequest,
                attachmentHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)response;

            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                openEmbeddedMessageResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion
        }