public void MSOXCROPS_S05_TC02_TestRopAbortSubmit()
        {
            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 submit message.

            // Log on to a private mailbox.
            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);
            uint logonHandle = responseSOHs[0][logonResponse.OutputHandleIndex];
            int runTimes = 0;
            int runTimesLimit = 10;
            bool abortSubmitFailed = false;
            do
            {
                #region Create, modify recipients and submit message

                // 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 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 messageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

                #endregion

                // Configure recipients.
                #region Configure 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,
                    messageHandle,
                    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 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 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,
                    messageHandle,
                    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 messageId = saveChangesMessageResponse.MessageId;

                #endregion

                // Submit message.
                #region Submit message

                RopSubmitMessageRequest submitMessageRequest;
                RopSubmitMessageResponse submitMessageResponse;

                submitMessageRequest.RopId = (byte)RopId.RopSubmitMessage;
                submitMessageRequest.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.
                submitMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                submitMessageRequest.SubmitFlags = (byte)SubmitFlags.None;

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

                // Send the RopSubmitMessage request to the server and verify the success response.
                cropsAdapter.ProcessSingleRop(
                    submitMessageRequest,
                    messageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                submitMessageResponse = (RopSubmitMessageResponse)response;

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

                #endregion
                
                #endregion

                // Step 2: Send the RopAbortSubmit.
                #region RopAbortSubmit response

                RopAbortSubmitRequest abortSubmitRequest;
                RopAbortSubmitResponse abortSubmitResponse;

                abortSubmitRequest.RopId = (byte)RopId.RopAbortSubmit;
                abortSubmitRequest.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.
                abortSubmitRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

                // Set MessageId to that of created message, which identifies the submitted message.
                abortSubmitRequest.MessageId = messageId;

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

                // Send the RopAbortSubmit request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    abortSubmitRequest,
                    logonHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                abortSubmitResponse = (RopAbortSubmitResponse)response;
                Site.Assert.IsTrue(abortSubmitResponse.ReturnValue == 0 || abortSubmitResponse.ReturnValue == 0x80040601, "abort submit response fail, the error code is {0}", abortSubmitResponse.ReturnValue);
                
                // 0x80040601: The message is no longer in the spooler queue of the Message store. Specified in MS-OXOMSG 3.3.5.2
                abortSubmitFailed = abortSubmitResponse.ReturnValue == 0x80040601;

                #endregion
                runTimes++;
            }
            while (runTimes < runTimesLimit && abortSubmitFailed);

            // If abort submit failed, it means there are messages left in inbox which need to be deleted
            if (runTimes > 1)
            {
                this.DeleteSubFolderAndMessage(logonResponse.FolderIds[4]);

                if (runTimes == runTimesLimit)
                {
                    Site.Assert.Fail("Retry to send RopAbortSubmit {0} times, but fail to get successful RopAbortSubmit response since it always returns an error code 0x80040601 (The message is no longer in the spooler queue of the Message store. Specified in MS-OXOMSG 3.3.5.2).", runTimesLimit);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create message each one loop In InBox
        /// </summary>
        /// <param name="logonResponse">the logon response be used to create message</param>
        /// <param name="tableHandle">The tableHanlder of the new folder</param>
        /// <param name="count">The count of created messages</param>
        /// <param name="createMessageRequest">The ROP CreateMessageRequest</param>
        /// <param name="saveChangesMessageRequest">The ROP SaveChangesMessageRequest</param>
        /// <param name="releaseRequest">The ROP ReleaseRequest</param>
        protected void CreateSingleProcessEachLoop(ref RopLogonResponse logonResponse, out uint tableHandle, int count, RopCreateMessageRequest createMessageRequest, RopSaveChangesMessageRequest saveChangesMessageRequest, RopReleaseRequest releaseRequest)
        {
            RopCreateMessageResponse createMessageResponse = new RopCreateMessageResponse();
            RopSaveChangesMessageResponse saveChangesMessageResponse = new RopSaveChangesMessageResponse();
            #region Preparing the table: CreateFolder

            // Open a folder first
            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;

            openFolderRequest.LogonId = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            openFolderRequest.FolderId = logonResponse.FolderIds[4];
            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

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

            // Create a new subfolder in the opened folder
            // The new subfolder will be used as target folder
            RopCreateFolderRequest createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
            createFolderRequest.LogonId = TestSuiteBase.LogonId;
            createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            createFolderRequest.FolderType = (byte)FolderType.Genericfolder;
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;
            createFolderRequest.Reserved = TestSuiteBase.Reserved;
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
            createFolderRequest.Comment = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)this.response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createFolderResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
            tableHandle = this.GetContentsTableHandle(targetFolderHandle);
            ulong folderId = createFolderResponse.FolderId;

            #endregion

            #region Preparing the table: RopCreateAndSaveMessages

            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int maxRetryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int retryCount;
            uint returnValue = 0;
            for (int i = 1; i < count; i++)
            {
                // If the RPC report error code reported by the following three ROP methods is 1726 (The remote procedure call failed), 
                // re-do the common steps of this case.
                if (returnValue == 1726)
                {
                    #region The common steps
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
                    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));
                    logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);

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

                    this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                        openFolderRequest,
                        this.inputObjHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse);
                    openFolderResponse = (RopOpenFolderResponse)this.response;

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

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

                    this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                        createFolderRequest,
                        openedFolderHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse);
                    createFolderResponse = (RopCreateFolderResponse)this.response;
                    Site.Assert.AreEqual<uint>(
                        TestSuiteBase.SuccessReturnValue,
                        createFolderResponse.ReturnValue,
                        "if ROP succeeds, the ReturnValue of its response is 0(success)");
                    targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
                    tableHandle = this.GetContentsTableHandle(targetFolderHandle);
                    folderId = createFolderResponse.FolderId;
                    #endregion
                }

                #region Create message
                createMessageRequest.FolderId = folderId;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopCreateMessage request:loop counter i={0}", i);
                retryCount = maxRetryCount;

                do
                {
                    // Send the RopCreateMessage to create message.
                    this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
                        createMessageRequest,
                        this.inputObjHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse,
                        out returnValue);
                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while (this.response is RopBackoffResponse && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }

                createMessageResponse = (RopCreateMessageResponse)this.response;
                Site.Assert.AreEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    createMessageResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
                uint targetMessageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];
                #endregion

                #region Save message
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopSaveChangesMessage request:loop counter i={0}", i);

                retryCount = maxRetryCount;

                // Do the loop when response is RopBackoffResponse or saveChangesMessageResponse is 0x80040401 (ecTimeout).
                do
                {
                    // Send the RopSaveChangesMessage request to save the created message.
                    this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
                        saveChangesMessageRequest,
                        targetMessageHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse,
                        out returnValue);

                    if (this.response is RopSaveChangesMessageResponse)
                    {
                        saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;
                    }

                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while ((this.response is RopBackoffResponse || saveChangesMessageResponse.ReturnValue == 0x80040401) && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }

                saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;
                Site.Assert.AreEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    saveChangesMessageResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
                #endregion

                #region Release all resources
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopRelease request.");

                retryCount = maxRetryCount;

                do
                {
                    this.responseSOHs = this.cropsAdapter.ProcessSingleRopWithReturnValue(
                        releaseRequest,
                        targetMessageHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse,
                        out returnValue);
                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while (this.response is RopBackoffResponse && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy and always returns RopBackoff in the response, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }
                #endregion
            }

            // If the error code 1726 occurs on the last time of the above "for" loop, re-do the common steps.
            if (returnValue == 1726)
            {
                #region The common steps
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
                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));
                logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);

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

                this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                    openFolderRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                openFolderResponse = (RopOpenFolderResponse)this.response;

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

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

                this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                    createFolderRequest,
                    openedFolderHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                createFolderResponse = (RopCreateFolderResponse)this.response;
                Site.Assert.AreEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    createFolderResponse.ReturnValue,
                    "if ROP succeeds, the ReturnValue of its response is 0(success)");
                targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
                tableHandle = this.GetContentsTableHandle(targetFolderHandle);
                folderId = createFolderResponse.FolderId;
                #endregion
            }

            #endregion
        }
        public void MSOXCSTOR_S03_TC01_ReadPerUserInformationForPublicLogon()
        {
            this.CheckTransportIsSupported();

            #region Step 1: Connect to the server.
            this.returnStatus = this.oxcstorAdapter.ConnectEx(ConnectionType.PublicFolderServer);
            Site.Assert.IsTrue(this.returnStatus, "Connection is successful");
            #endregion

            #region Step 2: Logon to public folder.
            this.oxcstorAdapter.DoRopCall(this.logonRequestForPublicFolder, this.insideObjHandle, ROPCommandType.RopLogonPublicFolder, out this.outputBuffer);
            this.logonResponse = (RopLogonResponse)this.outputBuffer.RopsList[0];
            this.outObjHandle = this.outputBuffer.ServerObjectHandleTable[0];

            Site.Assert.AreEqual<uint>(
                0,
                this.logonResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region step 3: Open a public folder
            RopOpenFolderRequest openFolderRequest;
            openFolderRequest.RopId = 0x02;
            openFolderRequest.LogonId = ConstValues.LoginId;
            openFolderRequest.InputHandleIndex = ConstValues.InputHandleIndex;
            openFolderRequest.OutputHandleIndex = ConstValues.OutputHandleIndex;
            openFolderRequest.FolderId = this.logonResponse.FolderIds[1];
            openFolderRequest.OpenModeFlags = 0x0;

            this.oxcstorAdapter.DoRopCall(openFolderRequest, this.outObjHandle, ROPCommandType.Others, out this.outputBuffer);

            RopOpenFolderResponse openFolderResponse = (RopOpenFolderResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x0,
                openFolderResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            uint openedFolderHandle = this.outputBuffer.ServerObjectHandleTable[openFolderRequest.OutputHandleIndex];
            #endregion

            #region step 4: Create a public folder
            string publicFolderName = Common.GenerateResourceName(Site, "PublicFolder") + "\0";
            RopCreateFolderRequest createFolderRequest;
            createFolderRequest.RopId = 0x1C;
            createFolderRequest.LogonId = ConstValues.LoginId;
            createFolderRequest.InputHandleIndex = ConstValues.InputHandleIndex;
            createFolderRequest.OutputHandleIndex = ConstValues.OutputHandleIndex;
            createFolderRequest.FolderType = 0x01;
            createFolderRequest.UseUnicodeStrings = 0x0;
            createFolderRequest.OpenExisting = 0xFF;
            createFolderRequest.Reserved = 0x0;
            createFolderRequest.DisplayName = System.Text.Encoding.ASCII.GetBytes(publicFolderName);
            createFolderRequest.Comment = System.Text.Encoding.ASCII.GetBytes(publicFolderName);
            this.oxcstorAdapter.DoRopCall(createFolderRequest, openedFolderHandle, ROPCommandType.Others, out this.outputBuffer);
            RopCreateFolderResponse createFolderResponse = (RopCreateFolderResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x0,
                createFolderResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            ulong folderId = createFolderResponse.FolderId;
            uint folderHandle = this.outputBuffer.ServerObjectHandleTable[createFolderRequest.OutputHandleIndex];

            #endregion

            #region Step 5: Get LongTermID of the folder created in step 4.
            LongTermId longTermId = this.GetLongTermIdFromId(folderId);
            #endregion

            #region Step 6: Call RopReadPerUserInformation ROP request to check if user information exists.
            this.readPerUserInformationRequest.FolderId = longTermId;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, this.readPerUserInformationResponse.ReturnValue, "0 indicates the ROP succeeds, other value indicates error occurs.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1257.
            Site.CaptureRequirementIfIsNull(
                this.readPerUserInformationResponse.Data,
                1257,
                @"[In Public Folders Specific Behavior] If the row does not exist, then the server returns an empty array in the Data field of the response.");
            #endregion

            #region Step 7: Create a message in the public folder created in step 4.
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId = ConstValues.LoginId;
            createMessageRequest.InputHandleIndex = ConstValues.InputHandleIndex;
            createMessageRequest.OutputHandleIndex = ConstValues.OutputHandleIndex;
            createMessageRequest.CodePageId = 0x0FFF;
            createMessageRequest.FolderId = folderId;
            createMessageRequest.AssociatedFlag = 0x0;
            this.oxcstorAdapter.DoRopCall(createMessageRequest, folderHandle, ROPCommandType.Others, out this.outputBuffer);

            RopCreateMessageResponse createMessageResponse = (RopCreateMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, createMessageResponse.ReturnValue, "Creating Message should succeed");
            uint messageHandle = this.outputBuffer.ServerObjectHandleTable[createMessageRequest.OutputHandleIndex];

            // Save a Message.
            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest();
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = ConstValues.LoginId;
            saveChangesMessageRequest.InputHandleIndex = ConstValues.InputHandleIndex;
            saveChangesMessageRequest.ResponseHandleIndex = ConstValues.OutputHandleIndex;
            saveChangesMessageRequest.SaveFlags = 0x0C;
            this.oxcstorAdapter.DoRopCall(saveChangesMessageRequest, messageHandle, ROPCommandType.Others, out this.outputBuffer);
            RopSaveChangesMessageResponse saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0,
                saveChangesMessageResponse.ReturnValue,
                "Save Messages Success.");
            ulong messageId = saveChangesMessageResponse.MessageId;
            #endregion

            #region Step 8: Call RopReadPerUserInformation ROP request to get data.
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, this.readPerUserInformationResponse.ReturnValue, "0 indicates the ROP succeeds, other value indicates error occurs.");
            Site.Assert.IsNotNull(this.readPerUserInformationResponse.Data, "Data should be exist if user reads mail in public folder.");
            byte[] data = this.readPerUserInformationResponse.Data;

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R965.
            Site.CaptureRequirementIfAreEqual<uint>(
                0,
                this.readPerUserInformationResponse.ReturnValue,
                965,
                @"[In Receiving a RopReadPerUserInformation ROP Request] This operation [RopReadPerUserInformation] can be issued against either a private mailbox logon or a public folders logon.");
            #endregion

            #region Step 9: Call RopReadPerUserInformation MaxDataSize set to zero.
            this.readPerUserInformationRequest.MaxDataSize = 0;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, this.readPerUserInformationResponse.ReturnValue, "0 indicates the ROP succeeds, other value indicates error occurs.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1005
            // MaxDataSize be set to 0 server will use the default value 4096
            int adjMaxDataSize = 4096;
            int blobMinDataOffset = data.Length - (int)this.readPerUserInformationRequest.DataOffset;
            bool isVerify_R1005 = (blobMinDataOffset > adjMaxDataSize)
                ? (this.readPerUserInformationResponse.DataSize == adjMaxDataSize)
                : (this.readPerUserInformationResponse.DataSize == blobMinDataOffset);
            Site.CaptureRequirementIfIsTrue(
                isVerify_R1005,
                1005,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The server MUST set DataSize to the lesser of the following two values [the adjusted value of MaxDataSize, the entire BLOB minus the value of DataOffset.].");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1000.
            // The DataSize field in the RopReadPerUserInformation is the lesser of the following two values [the adjusted value of MaxDataSize, the entire BLOB minus the value of DataOffset.], it indicates the server compares the adjusted value of MaxDataSize to the size of the remaining BLOB segment.
            // MS-OXCSTOR_R1000 can be verified directly.
            Site.CaptureRequirement(
                1000,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] 	The server compares the adjusted value of MaxDataSize to the size of the remaining BLOB segment.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R517.
            Site.CaptureRequirementIfIsNotNull(
                this.readPerUserInformationResponse.Data,
                517,
                @"[In RopReadPerUserInformation ROP] When this ROP is issued against a public folders logon, the current per-user read/unread data for the public folder is retrieved.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R971.
            // MS-OXCSTOR_R517 has verified the server returned current per-user read/unread data for the public folder successfully, MS-OXCSTOR_R971 can be verified directly.
            Site.CaptureRequirement(
                971,
                @"[In Public Folders Specific Behavior] The server searches the per-user data table for the only row with an FID equal to the value of the FolderId field and the user ID equal to the logged on user.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R975
            // Verify the data is a BLOB which is formatted as a serialized IDSET with REPLGUID
            bool isVerify_R975 = this.VerifyDataIsIDSETStructure(this.readPerUserInformationResponse.Data);

            Site.CaptureRequirementIfIsTrue(
                isVerify_R975,
                975,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] [The change number set is serialized into a binary large object (BLOB) that is formatted as a serialized IDSET with REPLGUID structure, as specified in [MS-OXCFXICS] section 2.2.2.4.2.] The server then returns the BLOB in the Data field of the response.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R974.
            // MS-OXCSTOR_R975 has verified the change number set structure, MS-OXCSTOR_R545 can be verified directly.
            Site.CaptureRequirement(
                974,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The change number set MUST be serialized into a binary large object (BLOB) that is formatted as a serialized IDSET with REPLGUID structure, as specified in [MS-OXCFXICS] section 2.2.2.4.2.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1003
            Site.CaptureRequirementIfAreEqual<ushort>(
                (ushort)this.readPerUserInformationResponse.DataSize,
                (ushort)this.readPerUserInformationResponse.Data.Length,
                1003,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The DataSize field specifies the actual number of bytes that are returned in the response.");
            #endregion

            #region Step 10: RopReadPerUserInformation with DataOffset less than zero.
            this.readPerUserInformationRequest.DataOffset = 0xffffffff;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];

            #region Capture

            if (Common.IsRequirementEnabled(1042, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R1042");

                // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1042.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x80004005,
                    this.readPerUserInformationResponse.ReturnValue,
                    1042,
                    @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The implementation does fail the operation with 0x80004005 (ecError) in the ReturnValue field, if the value of the DataOffset field is less than zero. (Exchange 2013 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(1007, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCSTOR_R554");

                // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R554.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x000004B6,
                    this.readPerUserInformationResponse.ReturnValue,
                    554,
                    @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecRpcFormat: Its value is 0x000004B6.");

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

                // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R555.
                // MS-OXCSTOR_R554 was captured by calling RopReadPerUserInformation with DataOffset value less than zero, MS-OXCSTOR_R555 can be verified directly.
                Site.CaptureRequirement(
                    555,
                    @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecRpcFormat: The DataOffset value was less than zero.");

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

                // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1007.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x000004B6,
                    this.readPerUserInformationResponse.ReturnValue,
                    1007,
                    @"[In Appendix A: Product Behavior] The implementation does fail the operation with 0x000004B6 (ecRpcFormat) in the ReturnValue field, if the value of the DataOffset field is less than zero. (<46> Section 3.2.5.12.1: Exchange 2003, Exchange 2007, and Exchange 2010 fail the operation with 0x000004B6 (ecRpcFormat).)");
            }
            #endregion
            #endregion

            #region Step 11: The first call of RopReadPerUserInformation with MaxDataSize field set to 1.

            // In the response hasFinished should be false, only the first byte should be returned.
            this.readPerUserInformationRequest.DataOffset = 0;
            this.readPerUserInformationRequest.MaxDataSize = 1;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            RopReadPerUserInformationResponse perUserInformationPart1 = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R552.
            Site.CaptureRequirementIfAreEqual<uint>(
                0,
                perUserInformationPart1.ReturnValue,
                552,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecNone: Its value is 0x00000000.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R553.
            // The RopReadPerUserInformation ROP performs successfully and the ecNone error code was captured by MS-OXCSTOR_R552, MS-OXCSTOR_R553 can be verified directly.
            Site.CaptureRequirement(
                553,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecNone: Success.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1284.
            Site.CaptureRequirementIfAreEqual<byte>(
                0,
                perUserInformationPart1.HasFinished,
                1284,
                @"[In RopReadPerUserInformation ROP Success Response Buffer] HasFinished: The value of this field is FALSE if the last block of data is not being returned.");

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-OXCSTOR_R543,
                the value of the MaxDataSize field of the RopReadPerUserInformation ROP request is {0},
                the value of the DataSize field of the RopReadPerUserInformation ROP response is {1}.",
                this.readPerUserInformationRequest.MaxDataSize,
                perUserInformationPart1.DataSize);

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R543.
            bool isVerifiedR543 = perUserInformationPart1.DataSize <= this.readPerUserInformationRequest.MaxDataSize;

            Site.CaptureRequirementIfIsTrue(
                isVerifiedR543,
                543,
                @"[In RopReadPerUserInformation ROP Success Response Buffer] DataSize: The value of this field MUST be less than or equal to the value of the MaxDataSize field of the request.");
            #endregion

            #region Step 12: The second call of RopReadPerUserInformation with DataOffset field set to "1" and MaxDataSize field set to 0.

            // The remained bytes should be returned, and HasFinished should be true.
            this.readPerUserInformationRequest.DataOffset = 1;
            this.readPerUserInformationRequest.MaxDataSize = 0;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            RopReadPerUserInformationResponse perUserInformationPart2 = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];

            Site.Assert.AreEqual<uint>(
                0,
                perUserInformationPart2.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1002
            // At step8, read again for the remaining Blob segment
            // verify if the size of returned data is equal to dataSizeWritten(entire blob size) minus the value of DataOffset
            bool isVerify_R1002 = perUserInformationPart2.Data.Length == data.Length - this.readPerUserInformationRequest.DataOffset;
            Site.CaptureRequirementIfIsTrue(
                isVerify_R1002,
                1002,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The size of the remaining BLOB segment is equal to the size of the entire BLOB minus the value of DataOffset.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1009.
            // At step8, read again for the remaining Blob segment, 
            // verify if the size of returned data is equal to dataSizeWritten(entire blob size) minus the value of DataOffset.
            bool isVerify_R1009 = perUserInformationPart2.Data.Length == data.Length - this.readPerUserInformationRequest.DataOffset;
            Site.CaptureRequirementIfIsTrue(
                isVerify_R1009,
                1009,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] This [The size of the remaining BLOB segment] is equal to the size of the entire BLOB minus the value of DataOffset.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1010
            // Verify "HasFinshed" field is true "0x01" when the dataSize plus data offset equals the size of entire BloB
            Site.CaptureRequirementIfAreEqual<byte>(
                0x01,
                perUserInformationPart2.HasFinished,
                1010,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The server MUST set HasFinished to TRUE if DataOffset plus DataSize equals the size of the entire BLOB.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1011
            // "In other words" means a different statement, but for same verification logic with R1010
            Site.CaptureRequirementIfAreNotEqual<byte>(
                0x00,
                perUserInformationPart2.HasFinished,
                1011,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] In other words, when the server sends the last segment of the BLOB, HasFinished MUST be set to TRUE.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1008
            // Step8 is to read the remaining data after the first read at step7.
            // If the data size read at step8 is the remaining BLOB segment size, then could verify R1008
            bool isVerifiedR1008 = perUserInformationPart2.DataSize == perUserInformationPart1.DataSize + perUserInformationPart2.DataSize - this.readPerUserInformationRequest.DataOffset;

            Site.CaptureRequirementIfIsTrue(
                isVerifiedR1008,
                1008,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] This [The size of the remaining BLOB segment] is the size of the portion of the BLOB that remains to be sent to the client.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R540.
            Site.CaptureRequirementIfAreNotEqual<byte>(
                0,
                perUserInformationPart2.HasFinished,
                540,
                @"[In RopReadPerUserInformation ROP Success Response Buffer] HasFinished: The value of this field is TRUE if the last block of data is being returned.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R539.
            // MS-OXCSTOR_R540 and MS-OXCSTOR_R1284 was verified, MS-OXCSTOR_R539 can be verified directly.
            Site.CaptureRequirement(
                539,
                @"[In RopReadPerUserInformation ROP Success Response Buffer] HasFinished: Indicates whether the last block of data is being returned.");
            #endregion

            #region Step 13: RopReadPerUserInformation, read once with the DataOffset field is greater than the size of the next BLOB segment to be returned.

            this.readPerUserInformationRequest.DataOffset = 0;
            this.readPerUserInformationRequest.MaxDataSize = (ushort)(data.Length - 1);
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];

            // Read once with MaxDataSize = entireBlobSize -1, the returned value of hasFinished in the response will be false,
            // all the data except the last byte will be returned, remaining data in the server will be 1
            this.readPerUserInformationRequest.DataOffset = (ushort)(data.Length + 1);
            this.readPerUserInformationRequest.MaxDataSize = (ushort)(data.Length - 1);
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1260
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80004005,
                this.readPerUserInformationResponse.ReturnValue,
                1260,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] If the value of the DataOffset field is greater than the size of the next BLOB segment to be returned, the server MUST fail the operation with 0x80004005 (ecError) in the ReturnValue field.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R556
            Site.CaptureRequirementIfAreEqual<uint>(
                0x80004005,
                this.readPerUserInformationResponse.ReturnValue,
                556,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecError: Its value is 0x80004005.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R557.
            // MS-OXCSTOR_R556 has captured error code 0x80004005, MS-OXCSTOR_R557 can be verified directly.
            Site.CaptureRequirement(
                557,
                @"[In Behavior Common to Both Private Mailbox and Public Folder Logon] The error code ecError: The DataOffset value was greater than the data size.");
            #endregion

            #region Step 14: Disconnect and re-connect.
            this.oxcstorAdapter.DisconnectEx();
            this.oxcstorAdapter.ConnectEx(ConnectionType.PublicFolderServer);

            this.oxcstorAdapter.DoRopCall(this.logonRequestForPublicFolder, this.insideObjHandle, ROPCommandType.RopLogonPublicFolder, out this.outputBuffer);
            this.logonResponse = (RopLogonResponse)this.outputBuffer.RopsList[0];
            this.outObjHandle = this.outputBuffer.ServerObjectHandleTable[0];

            Site.Assert.AreEqual<uint>(
                0,
                this.logonResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion

            #region Step 15: Open the folder and get folder handle.
            // Root public folder
            openFolderRequest.FolderId = this.logonResponse.FolderIds[1];
            openFolderRequest.OpenModeFlags = 0x0;
            this.oxcstorAdapter.DoRopCall(openFolderRequest, this.outObjHandle, ROPCommandType.Others, out this.outputBuffer);
            openFolderResponse = (RopOpenFolderResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x0,
                openFolderResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            openedFolderHandle = this.outputBuffer.ServerObjectHandleTable[openFolderRequest.OutputHandleIndex];

            // Created public folder
            openFolderRequest.FolderId = folderId;
            openFolderRequest.OpenModeFlags = 0x0;
            this.oxcstorAdapter.DoRopCall(openFolderRequest, this.outObjHandle, ROPCommandType.Others, out this.outputBuffer);
            openFolderResponse = (RopOpenFolderResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x0,
                openFolderResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            folderHandle = this.outputBuffer.ServerObjectHandleTable[openFolderRequest.OutputHandleIndex];
            #endregion

            #region Step 16: Create a message in the folder again.
            this.oxcstorAdapter.DoRopCall(createMessageRequest, folderHandle, ROPCommandType.Others, out this.outputBuffer);

            createMessageResponse = (RopCreateMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, createMessageResponse.ReturnValue, "Creating Message should succeed");
            uint messageHandle2 = this.outputBuffer.ServerObjectHandleTable[createMessageRequest.OutputHandleIndex];

            // Save a Message.
            saveChangesMessageRequest = new RopSaveChangesMessageRequest();
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = ConstValues.LoginId;
            saveChangesMessageRequest.InputHandleIndex = ConstValues.InputHandleIndex;
            saveChangesMessageRequest.ResponseHandleIndex = ConstValues.OutputHandleIndex;
            saveChangesMessageRequest.SaveFlags = 0x0C;
            this.oxcstorAdapter.DoRopCall(saveChangesMessageRequest, messageHandle2, ROPCommandType.Others, out this.outputBuffer);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0,
                saveChangesMessageResponse.ReturnValue,
                "Save Messages Success.");
            ulong messageId2 = saveChangesMessageResponse.MessageId;
            #endregion

            #region Step 17: Call RopReadPerUserInformation ROP request again.
            this.readPerUserInformationRequest.FolderId = longTermId;
            this.readPerUserInformationRequest.MaxDataSize = 0x100;
            this.readPerUserInformationRequest.DataOffset = 0;
            this.oxcstorAdapter.DoRopCall(this.readPerUserInformationRequest, this.outObjHandle, ROPCommandType.RopReadPerUserInformation, out this.outputBuffer);
            this.readPerUserInformationResponse = (RopReadPerUserInformationResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(0, this.readPerUserInformationResponse.ReturnValue, "0 indicates the ROP succeeds, other value indicates error occurs.");
            Site.Assert.IsNotNull(this.readPerUserInformationResponse.Data, "Data should be exist if user marks mail as un-read in public folder.");
            bool isChanged = !this.ByteArrayEquals(this.readPerUserInformationResponse.Data, data);

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1027.
            Site.CaptureRequirementIfIsTrue(
                isChanged,
                1027,
                @"[In Public Folders Specific Behavior] If the row exists, the accumulated change number information MUST replace any existing values in the table.");

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

            // Verify MS-OXCSTOR requirement: MS-OXCSTOR_R1026.
            Site.CaptureRequirementIfIsTrue(
                isChanged,
                1026,
                @"[In Public Folders Specific Behavior] The server searches the per-user data table for the only row with a user ID equal to user ID associated with the session logon and an FID equal to a value of the FolderId field.");
            #endregion

            #region Step 17: Delete the folder created in step 4.
            RopDeleteFolderRequest deleteFolderRequest;
            deleteFolderRequest.RopId = 0x1D;
            deleteFolderRequest.LogonId = 0x00;
            deleteFolderRequest.InputHandleIndex = 0x00;

            // The folder and all of the Message objects in the folder are deleted.
            deleteFolderRequest.DeleteFolderFlags = 0x01;

            // Folder to be deleted
            deleteFolderRequest.FolderId = folderId;
            this.oxcstorAdapter.DoRopCall(deleteFolderRequest, openedFolderHandle, ROPCommandType.Others, out this.outputBuffer);
            RopDeleteFolderResponse deleteFolderResponse = (RopDeleteFolderResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0x00000000,
                deleteFolderResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            #endregion
        }
        public void MSOXCROPS_S11_TC03_TestRopSynchronizationImportReadStateChanges()
        {
            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: Create a message.
            #region Create message

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

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            // Construct the RopCreateMessage request.
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            
            createMessageRequest.LogonId = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            createMessageRequest.FolderId = logonResponse.FolderIds[4];
            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

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

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            // Construct the RopSaveChangesMessage request.
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            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 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

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

            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            // Construct the RopOpenFolder request.
            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
            openFolderRequest.LogonId = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            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 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)");

            // Get the handle of opened folder, which will be used as input handle in RopCreateFolder.
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 4: Configure a synchronization upload context.
            #region Configure a synchronization upload context

            RopSynchronizationOpenCollectorRequest synchronizationOpenCollectorRequest;
            RopSynchronizationOpenCollectorResponse synchronizationOpenCollectorResponse;

            // Construct the RopSynchronizationOpenCollector request.
            synchronizationOpenCollectorRequest.RopId = (byte)RopId.RopSynchronizationOpenCollector;
            synchronizationOpenCollectorRequest.LogonId = TestSuiteBase.LogonId;
            synchronizationOpenCollectorRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            synchronizationOpenCollectorRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            synchronizationOpenCollectorRequest.IsContentsCollector = Convert.ToByte(TestSuiteBase.Zero);

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

            // Send the RopSynchronizationOpenCollector request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                synchronizationOpenCollectorRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            synchronizationOpenCollectorResponse = (RopSynchronizationOpenCollectorResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                synchronizationOpenCollectorResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");
            uint synchronizationUploadContextHandle = responseSOHs[0][synchronizationOpenCollectorResponse.OutputHandleIndex];

            #endregion

            // Step 5: Send the RopSynchronizationImportReadStateChanges request.
            #region RopSynchronizationImportReadStateChanges response

            RopSynchronizationImportReadStateChangesRequest synchronizationImportReadStateChangesRequest =
                new RopSynchronizationImportReadStateChangesRequest();
            MessageReadState[] messageReadStates = new MessageReadState[1];
            MessageReadState messageReadState = new MessageReadState
            {
                MarkAsRead = Convert.ToByte(TestSuiteBase.Zero)
            };

            // Send the RopLongTermIdFromId request to convert a short-term ID into a long-term ID.
            #region RopLongTermIdFromId response

            RopLongTermIdFromIdRequest ropLongTermIdFromIdRequest = new RopLongTermIdFromIdRequest();
            RopLongTermIdFromIdResponse ropLongTermIdFromIdResponse;

            ropLongTermIdFromIdRequest.RopId = (byte)RopId.RopLongTermIdFromId;
            ropLongTermIdFromIdRequest.LogonId = TestSuiteBase.LogonId;
            ropLongTermIdFromIdRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            ropLongTermIdFromIdRequest.ObjectId = saveChangesMessageResponse.MessageId;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                ropLongTermIdFromIdRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            ropLongTermIdFromIdResponse = (RopLongTermIdFromIdResponse)response;

            #endregion

            byte[] messageID = new byte[22];
            Array.Copy(ropLongTermIdFromIdResponse.LongTermId.DatabaseGuid, 0, messageID, 0, 16);
            Array.Copy(ropLongTermIdFromIdResponse.LongTermId.GlobalCounter, 0, messageID, 16, 6);

            messageReadState.MessageId = messageID;
            messageReadState.MessageIdSize = 22;
            messageReadStates[0] = messageReadState;

            // Construct the RopSynchronizationImportReadStateChanges request.
            synchronizationImportReadStateChangesRequest.RopId = (byte)RopId.RopSynchronizationImportReadStateChanges;
            synchronizationImportReadStateChangesRequest.LogonId = TestSuiteBase.LogonId;
            synchronizationImportReadStateChangesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            synchronizationImportReadStateChangesRequest.MessageReadStates = messageReadStates;
            synchronizationImportReadStateChangesRequest.MessageReadStateSize = (ushort)messageReadStates[0].Size();

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                synchronizationImportReadStateChangesRequest,
                synchronizationUploadContextHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            // Test RopSynchronizationImportReadStateChanges failure response.
            synchronizationImportReadStateChangesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                synchronizationImportReadStateChangesRequest,
                synchronizationUploadContextHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);

            #endregion
        }
Пример #5
0
        /// <summary>
        /// Get Created Message Handle
        /// </summary>
        /// <param name="folderId">The folder Id be used to create message</param>
        /// <param name="logonHandle">The RopLogon object handle</param>
        /// <returns>Return created Message Handle</returns>
        protected uint GetCreatedMessageHandle(ulong folderId, uint logonHandle)
        {
            // Create a message object first.
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId = LogonId;
            createMessageRequest.InputHandleIndex = InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = OutputHandleIndex1;

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

            createMessageRequest.FolderId = folderId;
            createMessageRequest.AssociatedFlag = Convert.ToByte(Zero);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Begin to send the RopCreateMessage request in GetCreatedMessageHandle method.");

            // Send the RopCreateMessage to create message.
            this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                logonHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)this.response;

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

            // Get handle of message object, it will be used as input handle in next ROP
            uint messageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];
            return messageHandle;
        }
        public void MSOXCROPS_S04_TC01_TestRopReloadCachedInformation()
        {
            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: Send the RopCreateMessage request and verify the success response.
            #region RopCreateMessage success response

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

            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];

            if (createMessageResponse.HasMessageId == 0)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R1778");

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R1778
                // MessageId is null means not present
                Site.CaptureRequirementIfAreEqual<ulong?>(
                    null,
                    createMessageResponse.MessageId,
                    1778,
                    @"[In RopCreateMessage ROP Success Response Buffer,MessageId (8 bytes)]is not present if it[HasMessageId] is zero.");
            }

            #endregion

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

            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 2: 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

            // Step 3: Send the RopSaveChangesMessage request and verify the success response.
            #region RopSaveChangesMessage success response

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.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.
            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 3: 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)");

            // targetMessageHandle is OutputHandle of createMessageResponse and specified by the output index in the ROP createMessage request
            // program go here, then targetMessageHandle is useful
            Site.CaptureRequirement(
                4558,
                @"[In Processing a ROP Input Buffer] The handle assigned is then set in the Server object handle table at the location specified by the output index in the ROP request.");

            #endregion

            // Step 4: Send the RopReadRecipients request and verify the success response.
            #region RopReadRecipients success response

            RopReadRecipientsRequest readRecipientsRequest;
            RopReadRecipientsResponse readRecipientsResponse;

            readRecipientsRequest.RopId = (byte)RopId.RopReadRecipients;
            readRecipientsRequest.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.
            readRecipientsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set RowId, which specifies the recipient to start reading.
            readRecipientsRequest.RowId = TestSuiteBase.RowId;

            // Set Reserved, this field is reserved and MUST be set to 0.
            readRecipientsRequest.Reserved = TestSuiteBase.Reserved;

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

            // Send the RopReadRecipients request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                readRecipientsRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            readRecipientsResponse = (RopReadRecipientsResponse)response;

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

            #endregion

            // Step 5: Send the RopOpenMessag request and verify the success response.
            #region RopOpenMessag success response

            RopOpenMessageRequest openMessageRequest;
            RopOpenMessageResponse openMessageResponse;

            openMessageRequest.RopId = (byte)RopId.RopOpenMessage;
            openMessageRequest.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.
            openMessageRequest.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.
            openMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

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

            openMessageRequest.OpenModeFlags = (byte)MessageOpenModeFlags.ReadOnly;

            // Set MessageId to that of created message, which identifies the message to be opened.
            openMessageRequest.MessageId = saveChangesMessageResponse.MessageId;

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

            // Send the RopOpenMessage request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openMessageResponse = (RopOpenMessageResponse)response;

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

            #endregion

            // Step 6: Send the RopReloadCachedInformation request and verify the success response.
            #region RopReloadCachedInformation success response

            RopReloadCachedInformationRequest reloadCachedInformationRequest;
            RopReloadCachedInformationResponse reloadCachedInformationResponse;

            reloadCachedInformationRequest.RopId = (byte)RopId.RopReloadCachedInformation;
            reloadCachedInformationRequest.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.
            reloadCachedInformationRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set Reserved to 0x0000, this field is reserved and MUST be set to 0x0000.
            reloadCachedInformationRequest.Reserved = TestSuiteBase.Reserved;

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

            // Send the RopReloadCachedInformation request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                reloadCachedInformationRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            reloadCachedInformationResponse = (RopReloadCachedInformationResponse)response;

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

            #endregion

            // Step 7: Send the RopRemoveAllRecipients request and verify the success response.
            #region RopRemoveAllRecipients response

            RopRemoveAllRecipientsRequest removeAllRecipientsRequest;
            RopRemoveAllRecipientsResponse removeAllRecipientsResponse;

            removeAllRecipientsRequest.RopId = (byte)RopId.RopRemoveAllRecipients;
            removeAllRecipientsRequest.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.
            removeAllRecipientsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set Reserved to 0x0, this field is reserved and MUST be set to 0x00000000.
            removeAllRecipientsRequest.Reserved = TestSuiteBase.Reserved;

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

            // Send the RopRemoveAllRecipients request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                removeAllRecipientsRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            removeAllRecipientsResponse = (RopRemoveAllRecipientsResponse)response;

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

            #endregion

            // Step 8: Verify Reserved field and verify R2005
            #region Verify Reserved field and verify R2005

            // Set Reserved non-0x00000000 to get the reply.
            removeAllRecipientsRequest.Reserved = TestSuiteBase.Reserved;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                removeAllRecipientsRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            RopRemoveAllRecipientsResponse removeAllRecipientsResponse1 = (RopRemoveAllRecipientsResponse)response;

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R2005
            // If two response return value is the same, the reply is the same.
            Site.CaptureRequirementIfAreEqual<uint>(
                removeAllRecipientsResponse.ReturnValue,
                removeAllRecipientsResponse1.ReturnValue,
                2005,
                @"[In RopRemoveAllRecipients ROP Request Buffer,Reserved (4 bytes)]Reply is the same whether 0x00000000 or non-0x00000000 is used for this Field[Reserved].");

            #endregion

            // Step 9: Send the RopCreateMessage request and verify the failure response.
            #region RopCreateMessage failure response

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

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

            // Send the RopCreateMessage request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            createMessageResponse = (RopCreateMessageResponse)response;

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

            #endregion

            // Step 10: Send the RopSaveChangesMessage request and verify the failure response.
            #region RopSaveChangesMessage failure response

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

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

            // Send the RopSaveChangesMessage request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                saveChangesMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;

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

            #endregion

            // Step 11: Send the RopReadRecipients request and verify the failure response.
            #region RopReadRecipients failure response

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

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

            // Send the RopReadRecipients request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                readRecipientsRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            readRecipientsResponse = (RopReadRecipientsResponse)response;

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

            #endregion

            // Step 12: Send the RopOpenMessage request and verify the failure response.
            #region RopOpenMessage failure response

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

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

            // Send the RopOpenMessage request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openMessageRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            openMessageResponse = (RopOpenMessageResponse)response;

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

            #endregion

            // Step 13: Send the RopReloadCachedInformation request and verify the failure response.
            #region RopReloadCachedInformation failure response

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

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

            // Send the RopReloadCachedInformation request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                reloadCachedInformationRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            reloadCachedInformationResponse = (RopReloadCachedInformationResponse)response;

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

            #endregion
        }
        public void MSOXCROPS_S04_TC03_TestRopSetReadFlags()
        {
            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 and save message, then open the folder containing created message.            
            #region Create and save message, open folder containing created message

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

            // 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 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];

            // 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 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)");
            ulong messageId = saveChangesMessageResponse.MessageId;

            // Open the folder(Inbox) containing the created message.
            // The folder handle will be used as input handle in next ROP: SetReadFlags
            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 0x1, 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 folder of the logonResponse(INBOX), which specifies the folder to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            // Send the RopOpenFolder request 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 folderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

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

            RopSetReadFlagsRequest setReadFlagsRequest;
            RopSetReadFlagsResponse setReadFlagsResponse;

            setReadFlagsRequest.RopId = (byte)RopId.RopSetReadFlags;
            setReadFlagsRequest.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.
            setReadFlagsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            setReadFlagsRequest.ReadFlags = (byte)ReadFlags.Default;
            ulong[] messageIds = new ulong[1];
            messageIds[0] = messageId;

            // Set MessageIdCount, which specifies the number of identifiers in the MessageIds field.
            setReadFlagsRequest.MessageIdCount = (ushort)messageIds.Length;

            // Set MessageIds, which specify the messages that are to have their read flags changed.
            setReadFlagsRequest.MessageIds = messageIds;

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

            // Send the RopSetReadFlags request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setReadFlagsRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setReadFlagsResponse = (RopSetReadFlagsResponse)response;

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

            #endregion
        }
        public void MSOXCROPS_S02_TC02_TestRopCopy_EmptyAndHardDeleteFolder()
        {
            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: Open a 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 6th of logonResponse. This folder is to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[5];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            // Send a 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)");

            // Get the folder handle. This handle will be used as input handle in the following RopCreateFolder.
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 2: Create a subfolder under the opened folder.
            #region Create Folder

            RopCreateFolderRequest createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
            createFolderRequest.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.
            createFolderRequest.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.
            createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            createFolderRequest.FolderType = (byte)FolderType.Genericfolder;

            // Set UseUnicodeStrings to 0x0, which specifies the DisplayName and Comment are not specified in Unicode.
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);

            // Set OpenExisting to 0xFF(TRUE), which means the folder to be created will be opened when it is already existed.
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;

            // Set Reserved to 0x0. This field is reserved and MUST be set to 0.
            createFolderRequest.Reserved = TestSuiteBase.Reserved;

            // Set DisplayName, which specifies the name of the created folder.
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

            // Set Comment, which specifies the folder comment that is associated with the created folder.
            createFolderRequest.Comment = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            // Send a RopCreateFolder request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createFolderResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            // Get the folder handle, which will be used as source handle in the following RopMOveCopyMessages.
            uint createFolderHandle = responseSOHs[0][createFolderResponse.OutputHandleIndex];
            ulong targetFolderId = createFolderResponse.FolderId;

            #endregion

            // Step 3: Copy the created folder from Inbox to the second folder.
            #region RopCopyFolder Success Response

            List<uint> handleList = new List<uint>
            {
                // Add createFolderHandle into handleList, createFolderHandle will be used as source handle.
                // Add openedFolderHandle into handleList, openedFolderHandle will be used as destination handle, source and destination in the same folder.
                createFolderHandle, openedFolderHandle
            };
            RopCopyFolderRequest copyFolderRequest;
            RopCopyFolderResponse copyFolderResponse;

            // Make folder name distinct for every test run, in this way, one successful test run won't FAIL next test run.
            Random random = new Random();
            int folderNo = random.Next(MaxValueForRandom);
            string destinationTargetFolderName = "CopiedToHereByTest-" + folderNo.ToString() + "\0";

            copyFolderRequest.RopId = (byte)RopId.RopCopyFolder;
            copyFolderRequest.LogonId = TestSuiteBase.LogonId;

            // Set SourceHandleIndex to 0x00, which specifies the location in the Server object handle table
            // where the handle for the source Server object is stored.
            copyFolderRequest.SourceHandleIndex = TestSuiteBase.SourceHandleIndex0;

            // Set DestHandleIndex to 0x01, which specifies the location in the Server object handle table
            // where the handle for the destination Server object is stored.
            copyFolderRequest.DestHandleIndex = TestSuiteBase.DestHandleIndex;

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

            // Set UseUnicodeStrings to 0x0(FALSE), which specifies the DisplayName and Comment are not specified in Unicode.
            copyFolderRequest.UseUnicode = Convert.ToByte(TestSuiteBase.Zero);

            // Set WantRecursive to 0xFF(TRUE), which specifies that the copy is recursive.
            copyFolderRequest.WantRecursive = TestSuiteBase.NonZero;

            copyFolderRequest.FolderId = targetFolderId;
            copyFolderRequest.NewFolderName = Encoding.ASCII.GetBytes(destinationTargetFolderName);

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

            // Send the RopCopyFolder request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                copyFolderRequest,
                handleList,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            copyFolderResponse = (RopCopyFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                copyFolderResponse.ReturnValue,
                "If ROP succeeds, ReturnValue of its response will be 0 (success)");

            #endregion

            // Step 4: Create a message in the created 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.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            // Set FolderId to targetFolderId, which identifies the parent folder.
            createMessageRequest.FolderId = targetFolderId;

            // 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 4: 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 5: 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 5: 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 6: Open the second folder, and set it as Destination folder of RopMoveCopyMessages.
            #region Open folder

            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 0x1, 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 7th folder. This folder is to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[6];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 6: 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 destinationFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            handleList.Clear();

            // Add createFolderHandle into handleList. This handle will be used as source handle in the following RopMoveCopyMessages.
            handleList.Add(createFolderHandle);

            // Add createdestinationFolderHandleFolderHandle into handleList. This handle will be used as destination handle
            // in the following RopMoveCopyMessages.
            handleList.Add(destinationFolderHandle);
            ulong[] messageIds = new ulong[1];
            messageIds[0] = targetMessageId;

            #endregion

            // Step 7: Copy messages from created folder.
            #region RopMoveCopyMessages Success Response

            RopMoveCopyMessagesRequest moveCopyMessagesRequest;
            RopMoveCopyMessagesResponse moveCopyMessagesResponse;

            moveCopyMessagesRequest.RopId = (byte)RopId.RopMoveCopyMessages;
            moveCopyMessagesRequest.LogonId = TestSuiteBase.LogonId;

            // Set SourceHandleIndex to 0x0, which specifies the location in the Server object handle table
            // where the handle for the source Server object is stored.
            moveCopyMessagesRequest.SourceHandleIndex = TestSuiteBase.SourceHandleIndex0;

            // Set DestHandleIndex to 0x01, which specifies the location in the Server object handle table
            // where the handle for the destination Server object is stored.
            moveCopyMessagesRequest.DestHandleIndex = TestSuiteBase.DestHandleIndex;

            // Set MessageIdCount to the length of messageIds, which specifies the size of the MessageIds field.
            moveCopyMessagesRequest.MessageIdCount = (ushort)messageIds.Length;

            // Set MessageIds to messageIds, which specify which messages to move or copy.
            moveCopyMessagesRequest.MessageIds = messageIds;

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

            // Set WantCopy to 0xFF(TRUE), which specifies the operation is a copy.
            moveCopyMessagesRequest.WantCopy = TestSuiteBase.NonZero;

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

            // Send the RopMoveCopyMessages request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                moveCopyMessagesRequest,
                handleList,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            moveCopyMessagesResponse = (RopMoveCopyMessagesResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                moveCopyMessagesResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 8: Delete all messages and subfolders from a folder through RopEmptyFolder.
            #region RopEmptyFolder Response

            RopEmptyFolderRequest emptyFolderRequest;
            RopEmptyFolderResponse emptyFolderResponse;

            emptyFolderRequest.RopId = (byte)RopId.RopEmptyFolder;
            emptyFolderRequest.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.
            emptyFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Set WantDeleteAssociated to 0xFF(TRUE), which specifies the operation also deletes folder associated information (FAI) messages.
            emptyFolderRequest.WantDeleteAssociated = TestSuiteBase.NonZero;

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

            // Send the RopEmptyFolder request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                emptyFolderRequest,
                destinationFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            emptyFolderResponse = (RopEmptyFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                emptyFolderResponse.ReturnValue,
                "If ROP succeeds, ReturnValue of its response will be 0 (success)");

            #endregion

            // Step 9: Send RopCopyFolder request to the server and verify Null Destination Failure Response.
            #region RopCopyFolder Null Destination Failure Response

            // Use createFolderHandle as source handle, but no destination handle,
            // this will lead to a failure response.
            handleList.Clear();
            handleList.Add(createFolderHandle);

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

            // Send RopCopyFolder request to the server and verify Null Destination Failure Response.
            this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                copyFolderRequest,
                handleList,
                ref this.response,
                ref this.rawData,
                RopResponseType.NullDestinationFailureResponse);
            copyFolderResponse = (RopCopyFolderResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                copyFolderResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 10: Send RopMoveCopyMessages request to the server and verify Null Destination Failure Response.
            #region RopMoveCopyMessages Null Destination Failure Response

            // Use createFolderHandle as source handle, but no destination handle,
            // this will lead to a failure response.
            handleList.Clear();
            handleList.Add(createFolderHandle);

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

            // Send RopMoveCopyMessages request to the server and verify Null Destination Failure Response.
            this.responseSOHs = cropsAdapter.ProcessSingleRopWithMutipleServerObjects(
                moveCopyMessagesRequest,
                handleList,
                ref this.response,
                ref this.rawData,
                RopResponseType.NullDestinationFailureResponse);
            moveCopyMessagesResponse = (RopMoveCopyMessagesResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                moveCopyMessagesResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 11: Hard delete messages and sub folder in inbox folder through RopHardDeleteMessagesAndSubfolders.
            #region RopHardDeleteMessagesAndSubfolders Response

            RopHardDeleteMessagesAndSubfoldersRequest hardDeleteMessagesAndSubfoldersRequest;
            RopHardDeleteMessagesAndSubfoldersResponse hardDeleteMessagesAndSubfoldersResponse;

            hardDeleteMessagesAndSubfoldersRequest.RopId = (byte)RopId.RopHardDeleteMessagesAndSubfolders;
            hardDeleteMessagesAndSubfoldersRequest.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.
            hardDeleteMessagesAndSubfoldersRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Set WantDeleteAssociated to 0xFF(TRUE), which specifies the operation also deletes folder associated information (FAI) messages.
            hardDeleteMessagesAndSubfoldersRequest.WantDeleteAssociated = TestSuiteBase.NonZero;

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

            // Send RopHardDeleteMessagesAndSubfolders request to the server and verify the Response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                hardDeleteMessagesAndSubfoldersRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            hardDeleteMessagesAndSubfoldersResponse = (RopHardDeleteMessagesAndSubfoldersResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                hardDeleteMessagesAndSubfoldersResponse.ReturnValue,
                "If ROP succeeds, ReturnValue of its response will be 0 (success)");

            #endregion

            // Step 12: 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 12: Begin to send the RopRelease request.");

            // Send the RopRelease request to the server.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                releaseRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
        /// <summary>
        /// This ROP creates a Message object in a mailbox. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="folderId">This value identifies the parent folder.</param>
        /// <param name="associatedFlag">This flag specifies whether the message is a folder associated information (FAI) message.</param>
        /// <param name="createMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the created message.</returns>
        private uint RopCreateMessage(uint handle, ulong folderId, byte associatedFlag, out RopCreateMessageResponse createMessageResponse, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest()
            {
                RopId = (byte)RopId.RopCreateMessage,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                CodePageId = (ushort)CodePageId.SameAsLogonObject,
                FolderId = folderId,
                AssociatedFlag = associatedFlag
            };

            this.responseSOHsValue = this.ProcessSingleRop(createMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, createMessageResponse.ReturnValue, string.Format("RopCreateMessageResponse Failed! Error: 0x{0:X8}", createMessageResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][createMessageResponse.OutputHandleIndex];
        }
        public void MSOXCROPS_S03_TC01_TestTableROPsNoDependency()
        {
            this.CheckTransportIsSupported();

            // Step 1: Open a folder and create a subfolder.
            #region Preparing the table: CreateFolder

            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 the private mailbox.
            RopLogonResponse logonResponse = Logon(LogonType.Mailbox, this.userDN, out inputObjHandle);

            // Open a folder first.
            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 0x1, 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 4th folder of the logonResponse, which specifies the folder to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            // Send the RopOpenFolder request 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)");

            // Get the handle of the opened folder, which will be used in the following RopCreateFolder.
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            // Create a subfolder of the opened folder, which will be used as target folder in the following ROPs.
            RopCreateFolderRequest createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
            createFolderRequest.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.
            createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            createFolderRequest.FolderType = (byte)FolderType.Genericfolder;

            // Set UseUnicodeStrings to 0x0(FALSE), which specifies the DisplayName and Comment are not specified in Unicode.
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);

            // Set OpenExisting to 0xFF(TRUE), which means the folder being created will be opened when it is already existed.
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;

            // Set Reserved to 0x0. This field is reserved and MUST be set to 0.
            createFolderRequest.Reserved = TestSuiteBase.Reserved;

            // Set DisplayName, which specifies the name of the created folder.
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

            // Set Comment, which specifies the folder comment that is associated with the created folder.
            createFolderRequest.Comment = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            // Send the RopCreateFolder request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue, 
                createFolderResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            uint targetFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];
            uint tableHandle = GetContentsTableHandle(targetFolderHandle);
            ulong folderId = createFolderResponse.FolderId;

            #endregion

            // Step 2: Create and save a message.
            #region Preparing the table: RopCreateAndSaveMessages

            // 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 specifies the code page of Logon object will be used.
            createMessageRequest.CodePageId = TestSuiteBase.CodePageId;

            // Set FolderId to that of the opened folder, which identifies the parent folder.
            createMessageRequest.FolderId = folderId;

            // 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 2: 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)");

            // Get the handle of created message, which will be used in the following RopSaveChangesMessage.
            uint targetMessageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

            // Save message.
            RopSaveChangesMessageRequest saveChangesMessageRequest;

            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 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);
            RopSaveChangesMessageResponse saveChangesMessageResponse = (RopSaveChangesMessageResponse)response;

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

            #endregion

            // Step 3: Send a RopSetColumns request and verify the success response.
            #region RopSetColumns success response

            RopSetColumnsRequest setColumnsRequest;
            RopSetColumnsResponse setColumnsResponse;

            // Set propertyTags to a Sample ContentsTable PropertyTags created by CreateSampleContentsTablePropertyTags method.
            PropertyTag[] propertyTags = CreateSampleContentsTablePropertyTags();

            setColumnsRequest.RopId = (byte)RopId.RopSetColumns;
            setColumnsRequest.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.
            setColumnsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            setColumnsRequest.SetColumnsFlags = (byte)AsynchronousFlags.None;
            setColumnsRequest.PropertyTagCount = (ushort)propertyTags.Length;
            setColumnsRequest.PropertyTags = propertyTags;

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

            // Send the RopSetColumns request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setColumnsRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setColumnsResponse = (RopSetColumnsResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                setColumnsResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 4: Send a RopSetColumns request and verify the failure response.
            #region RopSetColumns failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setColumnsRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            setColumnsResponse = (RopSetColumnsResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                setColumnsResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 5: Send a RopQueryRows request and verify the success response.
            #region RopQueryRows success response

            RopQueryRowsRequest queryRowsRequest;
            RopQueryRowsResponse queryRowsResponse;

            queryRowsRequest.RopId = (byte)RopId.RopQueryRows;
            queryRowsRequest.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.
            queryRowsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            queryRowsRequest.QueryRowsFlags = (byte)QueryRowsFlags.Advance;

            // Set ForwardRead to 0x01(TRUE), which specifies the direction to read rows (forwards).
            queryRowsRequest.ForwardRead = TestSuiteBase.NonZero;

            // Set RowCount to 0x0032, which specifies the number of requested rows.
            queryRowsRequest.RowCount = TestSuiteBase.RowCount;

            List<ISerializable> ropRequests = new List<ISerializable>
            {
                setColumnsRequest, queryRowsRequest
            };

            List<uint> inputObjects = new List<uint>
            {
                tableHandle
            };

            List<IDeserializable> ropResponses = new List<IDeserializable>();

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

            // Send a RopQueryRows request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(
                ropRequests,
                inputObjects,
                ref ropResponses,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            queryRowsResponse = (RopQueryRowsResponse)ropResponses[1];

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

            #endregion

            // Step 6: Send a RopQueryRows request and verify the failure response.
            #region RopQueryRows failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                queryRowsRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            queryRowsResponse = (RopQueryRowsResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                queryRowsResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 7: Send a RopSortTable request and verify the success response.
            #region RopSortTable success response

            RopSortTableRequest sortTableRequest;
            RopSortTableResponse sortTableResponse;

            // Create a Sample SortOrders by calling the CreateSampleSortOrders method.
            SortOrder[] sortOrders = this.CreateSampleSortOrders();

            sortTableRequest.RopId = (byte)RopId.RopSortTable;
            sortTableRequest.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.
            sortTableRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            sortTableRequest.SortTableFlags = (byte)AsynchronousFlags.None;

            // Set SortOrderCount, which specifies how many SortOrder structures are present in the SortOrders field.
            sortTableRequest.SortOrderCount = (ushort)sortOrders.Length;

            // Set CategoryCount, which specifies the number of category SortOrder structures in the SortOrders field.
            sortTableRequest.CategoryCount = (ushort)(sortOrders.Length - 1);

            // Set ExpandedCount, which specifies the number of expanded categories in the SortOrders field.
            sortTableRequest.ExpandedCount = sortTableRequest.CategoryCount;

            sortTableRequest.SortOrders = sortOrders;

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

            // Send a RopSortTable request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                sortTableRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            sortTableResponse = (RopSortTableResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                sortTableResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 8: Send a RopSortTable request and verify the failure response.
            #region RopSortTable failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                sortTableRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            sortTableResponse = (RopSortTableResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                sortTableResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 9: Send a RopRestrict request and verify the success response.
            #region RopRestrict success response

            RopRestrictRequest restrictRequest;
            RopRestrictResponse restrictResponse;

            restrictRequest.RopId = (byte)RopId.RopRestrict;
            restrictRequest.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.
            restrictRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            restrictRequest.RestrictFlags = (byte)AsynchronousFlags.None;

            // Set RestrictionDataSize, which specifies the length of the RestrictionData field.
            restrictRequest.RestrictionDataSize = TestSuiteBase.RestrictionDataSize2;

            // Set RestrictionData to null, which specifies there is no filter for limiting the view of a table to particular set of rows,
            // as specified in [MS-OXCDATA].
            restrictRequest.RestrictionData = null;

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

            // Send a RopRestrict request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                restrictRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            restrictResponse = (RopRestrictResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                restrictResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 10: Send a RopRestrict request and verify the failure response.
            #region RopRestrict failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                restrictRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            restrictResponse = (RopRestrictResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                restrictResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 11: Send a RopQueryPosition request and verify the success response.
            #region RopQueryPosition success response

            RopQueryPositionRequest queryPositionRequest;
            RopQueryPositionResponse queryPositionResponse;

            queryPositionRequest.RopId = (byte)RopId.RopQueryPosition;
            queryPositionRequest.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.
            queryPositionRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send a RopQueryPosition request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                queryPositionRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            queryPositionResponse = (RopQueryPositionResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                queryPositionResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");

            #endregion

            // Step 12: Send a RopQueryPosition request and verify the failure response.
            #region RopQueryPosition failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                queryPositionRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            queryPositionResponse = (RopQueryPositionResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                queryPositionResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion

            // Step 13: Send a RopQueryColumnsAll request and verify the success response.
            #region RopQueryColumnsAll success response

            RopQueryColumnsAllRequest queryColumnsAllRequest;
            RopQueryColumnsAllResponse queryColumnsAllResponse;

            queryColumnsAllRequest.RopId = (byte)RopId.RopQueryColumnsAll;
            queryColumnsAllRequest.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.
            queryColumnsAllRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send a RopQueryColumnsAll request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                queryColumnsAllRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            queryColumnsAllResponse = (RopQueryColumnsAllResponse)response;

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

            #endregion

            // Step 14: Send a RopQueryColumnsAll request and verify the failure response.
            #region RopQueryColumnsAll failure response

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

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                queryColumnsAllRequest,
                tableHandle,
                ref this.response,
                ref this.rawData, 
                RopResponseType.FailureResponse);
            queryColumnsAllResponse = (RopQueryColumnsAllResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue, 
                queryColumnsAllResponse.ReturnValue,
                "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");
            #endregion

            // Step 15: Send a RopResetTable request and verify the success response.
            #region RopResetTable success response

            RopResetTableRequest resetTableRequest;
            RopResetTableResponse resetTableResponse;

            resetTableRequest.RopId = (byte)RopId.RopResetTable;
            resetTableRequest.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.
            resetTableRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send a RopResetTable request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                resetTableRequest,
                tableHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            resetTableResponse = (RopResetTableResponse)response;

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

            #endregion

            // Step 16: Send a RopResetTable request and verify the failure response.
            #region RopResetTable failure response

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                resetTableRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            resetTableResponse = (RopResetTableResponse)response;

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

            #endregion

            // Step 17: Send a RopResetTable request and verify the success and failure response.
            #region RopGetStatus

            // Refer to MS-OXCTABL endnote<11>: Exchange 2010 and Exchange 2013 do not support asynchronous operations(RopGetStatus) 
            // on tables and ignore the TABL_ASYNC flags.
            if (Common.IsRequirementEnabled(60401, this.Site))
            {
                RopGetStatusRequest getStatusRequest;
                RopGetStatusResponse getStatusResponse;

                getStatusRequest.RopId = (byte)RopId.RopGetStatus;
                getStatusRequest.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.
                getStatusRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 17: Begin to send the RopResetTable request to invoke success response.");

                // Send a RopResetTable request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    getStatusRequest,
                    tableHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                getStatusResponse = (RopGetStatusResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R60401
                Site.CaptureRequirementIfAreEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    getStatusResponse.ReturnValue,
                    60401,
                    @"[In Appendix A: Product Behavior] Implementation does support asynchronous operations(RopGetStatus) on tables and ignore the TABL_ASYNC flags, as described in section 2.2.2.1.4. (Exchange 2007 follow this behavior.)");

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

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 17: Begin to send the RopResetTable request to invoke failure response.");

                // Send a RopResetTable request and verify the failure response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    getStatusRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.FailureResponse);
                getStatusResponse = (RopGetStatusResponse)response;

                Site.Assert.AreNotEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    getStatusResponse.ReturnValue,
                    "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");
            }
            #endregion
        }
Пример #11
0
        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
        }
        /// <summary>
        /// Create and save a message.
        /// </summary>
        /// <param name="folderID">The folder id of parent folder.</param>
        private void CreateAndSaveMessage(ulong folderID)
        {
            // Step 1: 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 that of the opened folder, which identifies the parent folder.
            createMessageRequest.FolderId = folderID;

            // 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 in CreateAndSaveMessage method.");

            // 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 the created message

            RopSaveChangesMessageRequest saveChangesMessageRequest;

            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 2: Begin to send the RopSaveChangesMessage request in CreateAndSaveMessage method.");

            // 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);

            #endregion

            // Step 3: Release the server object.
            #region Release the server object

            RopReleaseRequest releaseRequest;
            releaseRequest.RopId = (byte)RopId.RopRelease;
            releaseRequest.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.
            releaseRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send the RopRelease request to release the server object.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                releaseRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
        public void MSOXCROPS_S05_TC06_TestRopSpoolerLockMessage()
        {
            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: Preparations-Create and save message.
            #region Create and save message

            // 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 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

            // 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 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)");
            ulong messageId = saveChangesMessageResponse.MessageId;

            #endregion

            #endregion

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

            RopSetSpoolerRequest setSpoolerRequest;
            RopSetSpoolerResponse setSpoolerResponse;

            setSpoolerRequest.RopId = (byte)RopId.RopSetSpooler;
            setSpoolerRequest.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.
            setSpoolerRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send the RopSetSpooler request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setSpoolerRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setSpoolerResponse = (RopSetSpoolerResponse)response;

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

            #endregion

            // Step 3: Send the RopSpoolerLockMessage request and verify the success response.
            #region RopSpoolerLockMessage response with the field LockState value is Lock

            RopSpoolerLockMessageRequest spoolerLockMessageRequest;

            spoolerLockMessageRequest.RopId = (byte)RopId.RopSpoolerLockMessage;
            spoolerLockMessageRequest.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.
            spoolerLockMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set MessageId to that of created message, which identifies the message for which the status will be changed.
            spoolerLockMessageRequest.MessageId = messageId;

            spoolerLockMessageRequest.LockState = (byte)LockState.Lock;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopSpoolerLockMessage request with the field LockState value is Lock.");

            // Send the RopSpoolerLockMessage request to the server and verify the response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                spoolerLockMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.Response);

            #endregion

            #region RopSpoolerLockMessage response with the field LockState value is Unlock

            spoolerLockMessageRequest.LockState = (byte)LockState.Unlock;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopSpoolerLockMessage request with the field LockState value is Unlock.");

            // Send the RopSpoolerLockMessage request to the server and verify the response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                spoolerLockMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.Response);

            #endregion

            #region RopSpoolerLockMessage response with the field LockState value is Finished

            spoolerLockMessageRequest.LockState = (byte)LockState.Finished;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopSpoolerLockMessage request with the field LockState value is Finished.");

            // Send the RopSpoolerLockMessage request to the server and verify the response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                spoolerLockMessageRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.Response);

            #endregion
        }
        public void MSOXCROPS_S05_TC01_TestRopSubmitMessage()
        {
            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.
            #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 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 messageHandle = responseSOHs[0][createMessageResponse.OutputHandleIndex];

            #endregion

            // Step 2: Configure recipients.
            #region Configure 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;

            // Set recipientColumns to null, which means no property values are included for each recipient.
            PropertyTag[] recipientColumns = null;

            // Call CreateSampleRecipientColumnsAndRecipientRows method to create Recipient Rows and Recipient Columns.
            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 2: Begin to send the RopModifyRecipients request.");

            // Send the RopModifyRecipients request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                modifyRecipientsRequest,
                messageHandle,
                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

            // Step 3: Send the RopSubmitMessage request and verify the success response.
            #region RopSubmitMessage response with the field SubmitFlags value is None

            #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 1: 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 targetFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            #region Send RopGetContentsTable request

            RopGetContentsTableRequest getContentsTableRequest;
            RopGetContentsTableResponse getContentsTableResponse;

            getContentsTableRequest.RopId = (byte)RopId.RopGetContentsTable;
            getContentsTableRequest.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.
            getContentsTableRequest.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.
            getContentsTableRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            getContentsTableRequest.TableFlags = (byte)FolderTableFlags.None;

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

            // Send a RopGetContentsTable request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getContentsTableRequest,
                targetFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getContentsTableResponse = (RopGetContentsTableResponse)response;

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

            // The mail count before send RopSubmitMessage request.
            uint mailCount = getContentsTableResponse.RowCount;

            #endregion

            #region Send RopSubmitMessage request
            RopSubmitMessageRequest submitMessageRequest;

            submitMessageRequest.RopId = (byte)RopId.RopSubmitMessage;
            submitMessageRequest.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.
            submitMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            submitMessageRequest.SubmitFlags = (byte)SubmitFlags.None;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Step 3: Begin to send the RopSubmitMessage request with the field SubmitFlags value is None.");

            // Send the RopSubmitMessage request to the server and verify the response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                submitMessageRequest,
                messageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.Response);
            #endregion

            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            while (retryCount >= 0)
            {
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getContentsTableRequest,
                targetFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
                getContentsTableResponse = (RopGetContentsTableResponse)response;

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

                retryCount--;
                System.Threading.Thread.Sleep(waitTime);

                if (getContentsTableResponse.RowCount == mailCount + 1)
                {
                    break;
                }

                if (retryCount < 0)
                {
                    Site.Assert.Fail("The message fails to be submitted to server by sending RopSubmitMessage request.");
                }
            }

            #endregion
        }
        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
        }
        public void MSOXCROPS_S10_TC01_TestRopFastTransferSourceCopyMessages()
        {
            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: Send the RopCreateMessage request to create a message
            #region RopCreateMessage success response

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

            // Create a message
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;

            createMessageRequest.LogonId = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            // Create a message in INBOX
            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.");

            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: Send the RopSaveChangesMessage request to save changes
            #region RopSaveChangesMessage success response

            // Save message 
            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            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.");

            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 messageId = saveChangesMessageResponse.MessageId;

            #endregion

            // Step 3: Send the RopOpenFolder request to open folder containing created message
            #region RopOpenFoldersuccess response

            // Open the folder(Inbox) containing the created message
            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
            openFolderRequest.LogonId = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // Inbox will 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.");

            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 folderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

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

            #endregion

            // Step 4: Send the RopFastTransferSourceCopyMessages request to verify success response
            #region RopFastTransferSourceCopyMessages success response

            RopFastTransferSourceCopyMessagesRequest fastTransferSourceCopyMessagesRequest;
            RopFastTransferSourceCopyMessagesResponse fastTransferSourceCopyMessagesResponse;

            fastTransferSourceCopyMessagesRequest.RopId = (byte)RopId.RopFastTransferSourceCopyMessages;
            fastTransferSourceCopyMessagesRequest.LogonId = TestSuiteBase.LogonId;
            fastTransferSourceCopyMessagesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            fastTransferSourceCopyMessagesRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            fastTransferSourceCopyMessagesRequest.MessageIdCount = (ushort)messageIds.Length;
            fastTransferSourceCopyMessagesRequest.MessageIds = messageIds;
            fastTransferSourceCopyMessagesRequest.CopyFlags = (byte)RopFastTransferSourceCopyMessagesCopyFlags.BestBody;
            fastTransferSourceCopyMessagesRequest.SendOptions = (byte)SendOptions.ForceUnicode;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferSourceCopyMessagesRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            fastTransferSourceCopyMessagesResponse = (RopFastTransferSourceCopyMessagesResponse)response;

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

            #endregion
        }
        public void MSOXCROPS_S04_TC08_TestMultipleROPs()
        {
            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: Construct RopOpenFolder request.
            #region Open folder

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

            RopOpenFolderRequest openFolderRequest;
            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 0x1, 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 folder of the logonResponse(INBOX), which specifies the folder to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

            #endregion

            // Step 2: Construct RopCreateMessage request.
            #region Create message

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest
            {
                RopId = (byte)RopId.RopCreateMessage,
                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.
                InputHandleIndex = TestSuiteBase.InputHandleIndex1,
                
                // Set OutputHandleIndex to 0x02, which specifies the location in the Server object handle table where the handle for the output Server object will be stored.
                OutputHandleIndex = TestSuiteBase.OutputHandleIndex2,

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

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

                // Set AssociatedFlag to 0x00, which specified this message is not a folder associated information (FAI) message.
                AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero)
            };
            #endregion

            // Step 3: Construct RopSaveChangesMessage request.
            #region Save message

            RopSaveChangesMessageRequest saveChangesMessageRequest;

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

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

            // Set ResponseHandleIndex to 0x03, which specifies the location in the Server object handle table that is referenced
            // in the response.
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex2;

            saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;

            #endregion

            // Step 4: Send multiple ROPs request.
            #region Send multiple ROPs request

            List<ISerializable> ropRequests = new List<ISerializable>
            {
                openFolderRequest,
                createMessageRequest,
                saveChangesMessageRequest
            };

            List<uint> inputObjects = new List<uint>
            {
                // 0xFFFF indicates a default input handle.
                this.inputObjHandle, 0xFFFF, 0xFFFF, 0xFFFF
            };

            List<IDeserializable> ropResponses = new List<IDeserializable>();

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Begin to send the multiple ROPs request.");

            // Send multiple ROPs request.
            this.responseSOHs = cropsAdapter.ProcessMutipleRops(
                ropRequests,
                inputObjects,
                ref ropResponses,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion

            #region Verify R4559, R4550, R4565 and R4719

            RopSaveChangesMessageResponse ropSaveChangesMessageResponse = (RopSaveChangesMessageResponse)ropResponses[2];
            bool isVerifyR4559 = ropSaveChangesMessageResponse.ReturnValue == 0;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R4559,the actual value is {0}.", isVerifyR4559);

            // The RopSaveChangesMessageRequest uses the handle of created message, so success of RopSaveChangesMessage
            // means R4559 is verified.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR4559,
                4559,
                @"[In Processing a ROP Input Buffer,The handle assigned is then set in the Server object handle table at the location specified by the output index in the ROP request] And can be used by subsequent ROP requests in the same ROP input buffer.");

            // The request order is openFolderRequest, createMessageRequest, saveChangesMessageRequest,
            // isVerifyR4550 indicates whether the orders in request and response are same.
            bool isVerifyR4550 = (typeof(RopOpenFolderResponse) == ropResponses[0].GetType())
                                 && (typeof(RopCreateMessageResponse) == ropResponses[1].GetType())
                                 && (typeof(RopSaveChangesMessageResponse) == ropResponses[2].GetType());

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R4550,the actual value is {0}.", isVerifyR4550);

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R4550
            // True means the orders in request and response are same.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR4550,
                4550,
                @"[In Processing a ROP Input Buffer] The ROP responses in the  ROP output buffer MUST  be in the same order in which they were processed.");

            // The request order is openFolderRequest, createMessageRequest, saveChangesMessageRequest,
            // isVerifyR4719 indicates whether the orders in request and response are same.
            bool isVerifyR4719 = (typeof(RopOpenFolderResponse) == ropResponses[0].GetType())
                                 && (typeof(RopCreateMessageResponse) == ropResponses[1].GetType())
                                 && (typeof(RopSaveChangesMessageResponse) == ropResponses[2].GetType());

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R4719,the actual value is {0}.", isVerifyR4719);

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R4719
            // True means the orders in request and response are same.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR4719,
                4719,
                @"[In Creating a ROP Output Buffer] The ROP responses in the ROP output buffer MUST be in the same order in which they were processed.");

            // The request order is openFolderRequest, createMessageRequest, saveChangesMessageRequest,
            // isVerifyR4565 indicates whether the orders in request and response are same.
            bool isVerifyR4565 = (typeof(RopOpenFolderResponse) == ropResponses[0].GetType())
                                 && (typeof(RopCreateMessageResponse) == ropResponses[1].GetType())
                                 && (typeof(RopSaveChangesMessageResponse) == ropResponses[2].GetType());

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R4565,the actual value is {0}.", isVerifyR4565);

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R4565
            // True means the orders in request and response are same.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR4565,
                4565,
                @"[In Creating a ROP Output Buffer]  The server MUST preserve the order of entries in the Server object handle table between the ROP input buffer and the ROP output buffer.");

            #endregion
        }
        public void MSOXCROPS_S10_TC07_TestRopFastTransferSourceCopyProperties()
        {
            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: Send the RopCreateMessage request to create a message
            #region RopCreateMessage success response

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

            // Create a message
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;

            createMessageRequest.LogonId = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            // Create a message in INBOX
            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.");

            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: Send the RopSaveChangesMessage request to save changes
            #region RopSaveChangesMessage success response

            // Save message 
            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            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.");

            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

            // Step 3: Send the RopFastTransferSourceCopyTo request to verify success response
            #region RopFastTransferSourceCopyTo response

            RopFastTransferSourceCopyPropertiesRequest fastTransferSourceCopyPropertiesRequest;

            PropertyTag[] messagePropertyTags = this.CreateMessageSamplePropertyTags();
            fastTransferSourceCopyPropertiesRequest.RopId = (byte)RopId.RopFastTransferSourceCopyProperties;
            fastTransferSourceCopyPropertiesRequest.LogonId = TestSuiteBase.LogonId;
            fastTransferSourceCopyPropertiesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            fastTransferSourceCopyPropertiesRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            // This value specifies the level at which the copy is occurring, which is specified in [MS-OXCROPS].
            fastTransferSourceCopyPropertiesRequest.Level = TestSuiteBase.LevelOfNonZero;

            // Move: the client identifies the FastTransfer operation being configured as a logical part of a larger object move operation.
            fastTransferSourceCopyPropertiesRequest.CopyFlags = (byte)RopFastTransferSourceCopyPropertiesCopyFlags.Move;

            fastTransferSourceCopyPropertiesRequest.SendOptions = (byte)SendOptions.Unicode;
            fastTransferSourceCopyPropertiesRequest.PropertyTagCount = (ushort)messagePropertyTags.Length;
            fastTransferSourceCopyPropertiesRequest.PropertyTags = messagePropertyTags;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                fastTransferSourceCopyPropertiesRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            #endregion
        }
        public void MSOXCROPS_S04_TC02_TestRopGetMessageStatus()
        {
            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 and save message, then open the folder containing created message.
            #region Create and save message, open folder containing created message

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

            // 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 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 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];

            // 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 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)");
            ulong messageId = saveChangesMessageResponse.MessageId;

            // Open the folder(Inbox) containing the created message.
            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 0x1, 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 folder of the logonResponse(INBOX), which specifies the folder to be opened.
            openFolderRequest.FolderId = logonResponse.FolderIds[4];

            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            // Send the RopOpenFolder request 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 folderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

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

            RopSetMessageStatusRequest setMessageStatusRequest;
            RopSetMessageStatusResponse setMessageStatusResponse;

            setMessageStatusRequest.RopId = (byte)RopId.RopSetMessageStatus;
            setMessageStatusRequest.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.
            setMessageStatusRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set MessageId to that of created message, which value identifies the message for which the status will be changed.
            setMessageStatusRequest.MessageId = messageId;

            setMessageStatusRequest.MessageStatusFlags = (uint)MessageStatusFlags.MsRemoteDownload;

            // Set MessageStatusMask, which specifies which bits in the MessageStatusFlags field are to be changed.
            setMessageStatusRequest.MessageStatusMask = TestSuiteBase.MessageStatusMask;

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

            // Send the RopSetMessageStatus request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setMessageStatusRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setMessageStatusResponse = (RopSetMessageStatusResponse)response;

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

            #endregion

            // Step 3: Send the RopGetMessageStatus request and verify the success response.
            #region RopGetMessageStatus success response

            RopGetMessageStatusRequest getMessageStatusRequest;

            getMessageStatusRequest.RopId = (byte)RopId.RopGetMessageStatus;
            getMessageStatusRequest.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.
            getMessageStatusRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set MessageId to that of created message, which identifies the message for which the status will be returned.
            getMessageStatusRequest.MessageId = messageId;

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

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

            // The response buffers for RopGetMessageStatus are the same as those for RopSetMessageStatus.
            setMessageStatusResponse = (RopSetMessageStatusResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                setMessageStatusResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");

            #endregion

            // Step 4: Send the RopSetMessageStatus request and verify the failure response.
            #region RopSetMessageStatus failure response

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

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

            // Send the RopSetMessageStatus request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setMessageStatusRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);
            setMessageStatusResponse = (RopSetMessageStatusResponse)response;

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

            #endregion

            // Step 5: Send the RopGetMessageStatus request and verify the failure response.
            #region RopGetMessageStatus failure response

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

            // Set MessageId to that of created message, which identifies the message for which the status will be returned.
            getMessageStatusRequest.MessageId = messageId;

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

            // Send the RopGetMessageStatus request and verify the failure response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getMessageStatusRequest,
                folderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);

            // The response buffers for RopGetMessageStatus are the same as those for RopSetMessageStatus
            // MS-OXCROPS 2.2.5.9.2
            setMessageStatusResponse = (RopSetMessageStatusResponse)response;
            Site.Assert.AreNotEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                setMessageStatusResponse.ReturnValue,
               "If ROP fails, the ReturnValue of its response is set to a value other than 0x00000000(failure)");

            #endregion
        }
        /// <summary>
        /// Create a new message in the mail box folder of the user configured by "AdminUserName" by the logon user.
        /// </summary>
        /// <returns>The return value from the server. 0x00000000 indicates success, others indicate error occurs.</returns>
        public uint CreateMessageByLogonUser()
        {
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;
            createMessageRequest.RopId = 0x06; // RopId 0x06 indicates RopCreateMessage
            createMessageRequest.LogonId = 0x00; // The logonId 0x00 is associated with this operation.
            createMessageRequest.InputHandleIndex = 0x00; // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored. 
            createMessageRequest.OutputHandleIndex = 0x01; // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored. 
            createMessageRequest.CodePageId = 0x0FFF; // Code page of Logon object is used
            createMessageRequest.FolderId = this.ropLogonResponse.FolderIds[4]; // Create a message in INBOX which root is mailbox 
            createMessageRequest.AssociatedFlag = 0x00; // NOT an FAI message
            this.responseSOHs = this.DoRopCall(createMessageRequest, this.inobjHandle, ref this.response, ref this.rawData);
            createMessageResponse = (RopCreateMessageResponse)this.response;
            if (UINT32SUCCESS != createMessageResponse.ReturnValue)
            {
                return createMessageResponse.ReturnValue;
            }

            uint targetMessageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageRequest.RopId = 0x0C; // RopId 0x0C indicates RopSaveChangesMessage
            saveChangesMessageRequest.LogonId = 0x00; // The logonId 0x00 is associated with this operation.
            saveChangesMessageRequest.InputHandleIndex = 0x00; // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored. 
            saveChangesMessageRequest.ResponseHandleIndex = 0x01; // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored. 
            saveChangesMessageRequest.SaveFlags = 0x0C; // ForceSave
            this.DoRopCall(saveChangesMessageRequest, targetMessageHandle, ref this.response, ref this.rawData);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;

            if (saveChangesMessageResponse.ReturnValue == UINT32SUCCESS)
            {
                if (this.currentLogonUser == this.User2)
                {
                    this.messageIdsCreatedByOther.Add(saveChangesMessageResponse.MessageId);
                }
                else
                {
                    this.ownedMessageIds.Add(saveChangesMessageResponse.MessageId);
                }
            }

            // RopRelease created message 
            this.ReleaseObject(targetMessageHandle);

            return UINT32SUCCESS;
        }
        public void MSOXCROPS_S04_TC04_TestRopSetMessageReadFlags()
        {
            this.CheckTransportIsSupported();

            // Check whether the environment supported public folder.
            if (bool.Parse(Common.GetConfigurationPropertyValue("IsPublicFolderSupported", this.Site)))
            {
                this.cropsAdapter.RpcConnect(
                    Common.GetConfigurationPropertyValue("SutComputerName", this.Site),
                    ConnectionType.PublicFolderServer,
                    Common.GetConfigurationPropertyValue("UserEssdn", this.Site),
                    Common.GetConfigurationPropertyValue("Domain", this.Site),
                    Common.GetConfigurationPropertyValue("AdminUserName", this.Site),
                    Common.GetConfigurationPropertyValue("PassWord", this.Site));

                // Step 1: Open the second folder and create a subfolder.
                #region Open the second folder to create public folder under root folder

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

                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 0x1, 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 second folder of the logonResponse, which specifies the folder to be opened.
                openFolderRequest.FolderId = logonResponse.FolderIds[1];

                openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

                // Send the RopOpenFolder request 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 openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

                #endregion

                // Step 2: Create a non-ghosted public folder.
                #region Create a non-ghosted public folder

                RopCreateFolderRequest createFolderRequest;
                RopCreateFolderResponse createFolderResponse;

                createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
                createFolderRequest.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.
                createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

                createFolderRequest.FolderType = (byte)FolderType.Genericfolder;

                // Set UseUnicodeStrings to 0x0(FALSE), which specifies the DisplayName and Comment are not specified in Unicode.
                createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);

                // Set OpenExisting to 0xFF(TRUE), which means the folder being created will be opened when it is already existed,
                // as specified in [MS-OXCFOLD].
                createFolderRequest.OpenExisting = TestSuiteBase.NonZero;

                // Set Reserved to 0x0, this field is reserved and MUST be set to 0.
                createFolderRequest.Reserved = TestSuiteBase.Reserved;

                // Set new value for DisplayNameAndCommentForNonSearchFolder in Public Folder
                string displayNameAndCommentForNonSearchFolder = "MS-OXCROPSPublicFolder" + DisplayNameAndCommentForNonSearchFolder;

                // Set DisplayName, which specifies the name of the created folder.
                createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(displayNameAndCommentForNonSearchFolder + "\0");

                // Set Comment, which specifies the folder comment that is associated with the created folder.
                createFolderRequest.Comment = Encoding.ASCII.GetBytes(displayNameAndCommentForNonSearchFolder + "\0");

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

                // Send the RopCreateFolder request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    createFolderRequest,
                    openedFolderHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                createFolderResponse = (RopCreateFolderResponse)response;

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

                #endregion

                // Step 3: Open the folder containing the created message.
                #region Open folder

                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 0x1, 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 that of created folder, which specifies the folder to be opened.
                openFolderRequest.FolderId = folderId;

                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 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)");

                #endregion

                // Step 4: Create and save message.
                #region Create and save 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 that of created folder, which identifies the parent folder.
                createMessageRequest.FolderId = createFolderResponse.FolderId;

                // 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 4: 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

                #region RopModifyRecipients response

                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 4: 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

                #region Save message

                RopSaveChangesMessageRequest saveChangesMessageRequest;
                RopSaveChangesMessageResponse saveChangesMessageResponse;

                saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
                saveChangesMessageRequest.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.
                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 4: 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

                #endregion

                // Step 5: Send the RopCreateMessage request and verify the success response.
                #region RopLongTermIdFromId success response

                RopLongTermIdFromIdRequest longTermIdFromIdRequest;
                RopLongTermIdFromIdResponse longTermIdFromIdResponse;

                longTermIdFromIdRequest.RopId = (byte)RopId.RopLongTermIdFromId;
                longTermIdFromIdRequest.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.
                longTermIdFromIdRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                // Set ObjectId to that got in the foregoing code, this id will be converted to a short-term ID.
                longTermIdFromIdRequest.ObjectId = saveChangesMessageResponse.MessageId;

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

                // Send the RopLongTermIdFromId request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    longTermIdFromIdRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                longTermIdFromIdResponse = (RopLongTermIdFromIdResponse)response;

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

                #endregion

                // Step 6: Send the RopOpenMessag request and verify the success response.
                #region RopOpenMessag success response

                RopOpenMessageRequest openMessageRequest;
                RopOpenMessageResponse openMessageResponse;

                openMessageRequest.RopId = (byte)RopId.RopOpenMessage;
                openMessageRequest.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.
                openMessageRequest.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.
                openMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

                // Set FolderId to that of created folder, which identifies the parent folder.
                openMessageRequest.FolderId = createFolderResponse.FolderId;

                openMessageRequest.OpenModeFlags = (byte)MessageOpenModeFlags.ReadWrite;

                // Set MessageId to that of created message, which identifies the message to be opened.
                openMessageRequest.MessageId = saveChangesMessageResponse.MessageId;

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

                // Send the RopCreateMessage request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    openMessageRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                openMessageResponse = (RopOpenMessageResponse)response;

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

                #endregion

                // Step 7: Send the RopSetMessageReadFlag request and verify the success response.
                #region RopSetMessageReadFlag success response Test not changed

                RopSetMessageReadFlagRequest setMessageReadFlagRequest;
                RopSetMessageReadFlagResponse setMessageReadFlagResponse;

                setMessageReadFlagRequest.RopId = (byte)RopId.RopSetMessageReadFlag;
                setMessageReadFlagRequest.LogonId = TestSuiteBase.LogonId;

                // Set ResponseHandleIndex, which specifies the location in the Server object handle table that is referenced
                // in the response.
                setMessageReadFlagRequest.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.
                setMessageReadFlagRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                setMessageReadFlagRequest.ReadFlags = (byte)ReadFlags.GenerateReceiptOnly;

                // Set ClientData, which specifies the information that is returned to the client in a successful response.
                setMessageReadFlagRequest.ClientData = longTermIdFromIdResponse.LongTermId.Serialize();

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

                // Send the RopSetMessageReadFlag request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    setMessageReadFlagRequest,
                    targetMessageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;

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

                #endregion

                #region Verify R2110 and R2114

                if (setMessageReadFlagResponse.ReadStatusChanged == Convert.ToByte(TestSuiteBase.Zero))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2110");

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R2110
                    // LogonId is null means not present.
                    Site.CaptureRequirementIfAreEqual<byte?>(
                        null,
                        setMessageReadFlagResponse.LogonId,
                        2110,
                        @"[In RopSetMessageReadFlag ROP Success Response Buffer,LogonId (1 byte)]is not present otherwise[when the value in the ReadStatusChanged field is zero].");

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

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R2114
                    // ClientData is null means not present.
                    Site.CaptureRequirementIfIsNull(
                        setMessageReadFlagResponse.ClientData,
                        2114,
                        @"[In RopSetMessageReadFlag ROP Success Response Buffer,ClientData (24 bytes)]is not present otherwise[when the value in the ReadStatusChanged field is zero].");
                }

                #endregion

                // Step 8: Send the RopSetMessageReadFlag request and verify the success response.
                #region RopSetMessageReadFlag success response Test changed

                setMessageReadFlagRequest.RopId = (byte)RopId.RopSetMessageReadFlag;
                setMessageReadFlagRequest.LogonId = TestSuiteBase.LogonId;

                // Set ResponseHandleIndex, which specifies the location in the Server object handle table that is referenced
                // in the response.
                setMessageReadFlagRequest.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.
                setMessageReadFlagRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                setMessageReadFlagRequest.ReadFlags = (byte)ReadFlags.ClearReadFlag;

                // Set ClientData, which specifies the information that is returned to the client in a successful response.
                setMessageReadFlagRequest.ClientData = longTermIdFromIdResponse.LongTermId.Serialize();

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

                // Send the RopSetMessageReadFlag request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    setMessageReadFlagRequest,
                    targetMessageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;

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

                #endregion

                #region Verify R2109 and R2113

                if (setMessageReadFlagResponse.ReadStatusChanged != Convert.ToByte(TestSuiteBase.Zero))
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R2109");

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R2109
                    // LogonId is not null means present.
                    Site.CaptureRequirementIfIsNotNull(
                        setMessageReadFlagResponse.LogonId,
                        2109,
                        @"[In RopSetMessageReadFlag ROP Success Response Buffer,LogonId (1 byte)]This field is present when the value in the ReadStatusChanged field is nonzero.");

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

                    // Verify MS-OXCROPS requirement: MS-OXCROPS_R2113
                    // ClientData is not null means present.
                    Site.CaptureRequirementIfIsNotNull(
                        setMessageReadFlagResponse.ClientData,
                        2113,
                        @"[In RopSetMessageReadFlag ROP Success Response Buffer,ClientData (24 bytes)]This field is present when the value in the ReadStatusChanged field is nonzero.");
                }

                #endregion

                // Step 9: Send the RopSetMessageReadFlag request and verify the failure response.
                #region RopSetMessageReadFlag failure response

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

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

                // Send the RopSetMessageReadFlag request and verify the failure response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    setMessageReadFlagRequest,
                    targetMessageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.FailureResponse);
                setMessageReadFlagResponse = (RopSetMessageReadFlagResponse)response;

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

                #endregion

                // Step 10: Send a RopDeleteFolder request to the server.
                #region RopDeleteFolder Response
                RopDeleteFolderRequest deleteFolderRequest;

                deleteFolderRequest.RopId = (byte)RopId.RopDeleteFolder;
                deleteFolderRequest.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.
                deleteFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                deleteFolderRequest.DeleteFolderFlags = (byte)DeleteFolderFlags.DelMessages;

                // Set FolderId to targetFolderId, this folder is to be deleted.
                deleteFolderRequest.FolderId = folderId;

                // Send a RopDeleteFolder request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    deleteFolderRequest,
                    openedFolderHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                #endregion
            }
            else
            {
                Site.Assert.Inconclusive("This case runs only when the first system supports public folder logon.");
            }
        }
        /// <summary>
        /// Create a message and return the message handle created.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="folderHandleIndex">The folder handle index for creating message.</param>
        /// <param name="folderIdIndex">The folder Id index.</param>
        /// <param name="associatedFlag">The message is FAI or not.</param>
        /// <param name="messageHandleIndex">The created message handle index.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult CreateMessage(int serverId, int folderHandleIndex, int folderIdIndex, bool associatedFlag, out int messageHandleIndex)
        {
            // Initialize operation values.
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse = new RopCreateMessageResponse();
            messageHandleIndex = -1;
            uint folderHandle = this.handleContainer[folderHandleIndex];
            ulong folderId = this.objectIdContainer[folderIdIndex];
            RopResult result = RopResult.InvalidParameter;

            // Construct the RopCreateMessage request.
            createMessageRequest.RopId = 0x06;
            createMessageRequest.LogonId = 0x00;
            createMessageRequest.InputHandleIndex = 0x00;
            createMessageRequest.OutputHandleIndex = 0x01;

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

            // If the message is a FAImessage.
            createMessageRequest.AssociatedFlag = associatedFlag ? (byte)0x01 : (byte)0x00;

            // Send request and get ROP response.
            createMessageResponse = (RopCreateMessageResponse)this.Process(serverId, createMessageRequest, folderHandle);
            result = (RopResult)createMessageResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                messageHandleIndex = AdapterHelper.GetHandleIndex();
                this.handleContainer.Add(messageHandleIndex, this.responseSOHs[createMessageResponse.OutputHandleIndex]);

                this.AddRecipient(serverId, this.responseSOHs[createMessageResponse.OutputHandleIndex]);

                // Verify server Accept PidTagIdsetGivenPtypBinary
                this.VerifyServerAcceptPidTagIdsetGivenPtypBinary(serverId, folderHandleIndex);
            }

            return result;
        }
        public void MSOXCROPS_S11_TC05_TestRopSynchronizationImportDeletes()
        {
            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: Open folder.
            #region Open folder

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

            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            // Construct the RopOpenFolder request.
            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;
            
            openFolderRequest.LogonId = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            openFolderRequest.FolderId = logonResponse.FolderIds[4];
            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

            // Send the RopOpenFolder request 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)");

            // Get the handle of opened folder, which will be used as input handle in RopCreateFolder.
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 2: Configure a synchronization upload context.
            #region Configure a synchronization upload context

            RopSynchronizationOpenCollectorRequest synchronizationOpenCollectorRequest;
            RopSynchronizationOpenCollectorResponse synchronizationOpenCollectorResponse;

            // Construct the RopSynchronizationOpenCollector request.
            synchronizationOpenCollectorRequest.RopId = (byte)RopId.RopSynchronizationOpenCollector;
            synchronizationOpenCollectorRequest.LogonId = TestSuiteBase.LogonId;
            synchronizationOpenCollectorRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            synchronizationOpenCollectorRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            synchronizationOpenCollectorRequest.IsContentsCollector = Convert.ToByte(TestSuiteBase.Zero);

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

            // Send the RopSynchronizationOpenCollector request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                synchronizationOpenCollectorRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            synchronizationOpenCollectorResponse = (RopSynchronizationOpenCollectorResponse)response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                synchronizationOpenCollectorResponse.ReturnValue,
                "If ROP succeeds, the ReturnValue of its response is 0 (success)");
            uint synchronizationUploadContextHandle = responseSOHs[0][synchronizationOpenCollectorResponse.OutputHandleIndex];

            #endregion

            // Step 3: Create message.
            #region Create message

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;

            // Construct the RopCreateMessage request.
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            createMessageRequest.FolderId = logonResponse.FolderIds[4];
            createMessageRequest.AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero);

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

            // Step 4: Save message.
            #region Save message

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            // Construct the RopSaveChangesMessage request.
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
            saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;

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

            // Send the RopSaveChangesMessage request 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

            // Send the RopSynchronizationImportDeletes request and verify the response.
            #region RopSynchronizationImportDeletes response

            RopSynchronizationImportDeletesRequest ropSynchronizationImportDeletesRequest = new RopSynchronizationImportDeletesRequest();
            TaggedPropertyValue[] propertyValues = new TaggedPropertyValue[1];
            TaggedPropertyValue propertyValue = new TaggedPropertyValue();

            // Send the RopLongTermIdFromId request to convert a short-term ID into a long-term ID.
            #region RopLongTermIdFromId response

            RopLongTermIdFromIdRequest ropLongTermIdFromIdRequest = new RopLongTermIdFromIdRequest();
            RopLongTermIdFromIdResponse ropLongTermIdFromIdResponse;

            // Construct the RopLongTermIdFromId request.
            ropLongTermIdFromIdRequest.RopId = (byte)RopId.RopLongTermIdFromId;
            ropLongTermIdFromIdRequest.LogonId = TestSuiteBase.LogonId;
            ropLongTermIdFromIdRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            ropLongTermIdFromIdRequest.ObjectId = saveChangesMessageResponse.MessageId;

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

            // Send the RopGetPropertyIdsFromNames request.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                ropLongTermIdFromIdRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            ropLongTermIdFromIdResponse = (RopLongTermIdFromIdResponse)response;

            #endregion

            byte[] sampleValue = new byte[24];
            propertyValue.PropertyTag.PropertyId = this.propertyDictionary[PropertyNames.PidTagTemplateData].PropertyId;
            propertyValue.PropertyTag.PropertyType = this.propertyDictionary[PropertyNames.PidTagTemplateData].PropertyType;

            // The combination of first two bytes (0x0016) indicates the length of value field.
            sampleValue[0] = 0x16;
            sampleValue[1] = 0x00;
            Array.Copy(ropLongTermIdFromIdResponse.LongTermId.DatabaseGuid, 0, sampleValue, 2, 16);
            Array.Copy(ropLongTermIdFromIdResponse.LongTermId.GlobalCounter, 0, sampleValue, 18, 6);

            propertyValue.Value = sampleValue;
            propertyValues[0] = propertyValue;

            // Construct the RopSynchronizationImportDeletes request.
            ropSynchronizationImportDeletesRequest.RopId = (byte)RopId.RopSynchronizationImportDeletes;
            ropSynchronizationImportDeletesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            ropSynchronizationImportDeletesRequest.LogonId = TestSuiteBase.LogonId;
            ropSynchronizationImportDeletesRequest.IsHierarchy = Convert.ToByte(TestSuiteBase.Zero);
            ropSynchronizationImportDeletesRequest.PropertyValueCount = (ushort)propertyValues.Length;
            ropSynchronizationImportDeletesRequest.PropertyValues = propertyValues;

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

            // Send the RopSynchronizationImportDeletes request to get the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                ropSynchronizationImportDeletesRequest,
                synchronizationUploadContextHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            // Send the RopSynchronizationImportDeletes request to get the failure response.
            ropSynchronizationImportDeletesRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                ropSynchronizationImportDeletesRequest,
                synchronizationUploadContextHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.FailureResponse);

            #endregion
        }
Пример #24
0
        /// <summary>
        /// Create a message in public folder
        /// </summary>
        /// <param name="folderId">The ulong value</param>
        /// <param name="targetMessageHandle">The uint value</param>
        /// <returns>Return ulong value</returns>
        protected ulong CreateMessage(ulong folderId, out uint targetMessageHandle)
        {
            ulong messageId;

            #region Create a message
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse;
            createMessageRequest.RopId = 0x06;
            createMessageRequest.LogonId = 0x0;
            createMessageRequest.InputHandleIndex = 0x0;
            createMessageRequest.OutputHandleIndex = 0x01;
            createMessageRequest.CodePageId = 0x0FFF; // Code page of Logon object is used
            createMessageRequest.FolderId = folderId;
            createMessageRequest.AssociatedFlag = 0x00; // NOT an FAI message
            this.oxcstorAdapter.DoRopCall(createMessageRequest, this.outObjHandle, ROPCommandType.Others, out this.outputBuffer);
            createMessageResponse = (RopCreateMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0,
                createMessageResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            targetMessageHandle = this.outputBuffer.ServerObjectHandleTable[createMessageRequest.OutputHandleIndex];
            #endregion

            #region Save the message
            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageRequest.RopId = 0x0C;
            saveChangesMessageRequest.LogonId = 0x0;
            saveChangesMessageRequest.InputHandleIndex = 0x0;
            saveChangesMessageRequest.ResponseHandleIndex = 0x01;
            saveChangesMessageRequest.SaveFlags = 0x0C; // ForceSave
            this.oxcstorAdapter.DoRopCall(saveChangesMessageRequest, targetMessageHandle, ROPCommandType.Others, out this.outputBuffer);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.outputBuffer.RopsList[0];
            Site.Assert.AreEqual<uint>(
                0,
                saveChangesMessageResponse.ReturnValue,
                "0 indicates the ROP succeeds, other value indicates error occurs.");
            messageId = saveChangesMessageResponse.MessageId;
            #endregion

            return messageId;
        }
Пример #25
0
        /// <summary>
        /// Create Vast Messages In InBox
        /// </summary>
        /// <param name="logonResponse">the logon response be used to create message</param>
        /// <param name="tableHandle">The tableHanlder of the new folder</param>
        /// <param name="count">The count of created messages</param>
        /// <param name="createMessageRequest">The ROP CreateMessageRequest</param>
        /// <param name="saveChangesMessageRequest">The ROP SaveChangesMessageRequest</param>
        /// <param name="releaseRequest">The ROP ReleaseRequest</param>
        protected void CreateVastMessages(ref RopLogonResponse logonResponse, out uint tableHandle, int count, RopCreateMessageRequest createMessageRequest, RopSaveChangesMessageRequest saveChangesMessageRequest, RopReleaseRequest releaseRequest)
        {
            RopCreateMessageResponse createMessageResponse;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            #region Preparing the table: CreateFolder

            // Open a folder first
            RopOpenFolderRequest openFolderRequest;
            RopOpenFolderResponse openFolderResponse;

            openFolderRequest.RopId = (byte)RopId.RopOpenFolder;

            openFolderRequest.LogonId = TestSuiteBase.LogonId;
            openFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            openFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            openFolderRequest.FolderId = logonResponse.FolderIds[4];
            openFolderRequest.OpenModeFlags = (byte)FolderOpenModeFlags.None;

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

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

            // Create a new subfolder in the opened folder
            // The new subfolder will be used as target folder
            RopCreateFolderRequest createFolderRequest;
            RopCreateFolderResponse createFolderResponse;

            createFolderRequest.RopId = (byte)RopId.RopCreateFolder;
            createFolderRequest.LogonId = TestSuiteBase.LogonId;
            createFolderRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createFolderRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;
            createFolderRequest.FolderType = (byte)FolderType.Genericfolder;
            createFolderRequest.UseUnicodeStrings = Convert.ToByte(TestSuiteBase.Zero);
            createFolderRequest.OpenExisting = TestSuiteBase.NonZero;
            createFolderRequest.Reserved = TestSuiteBase.Reserved;
            createFolderRequest.DisplayName = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");
            createFolderRequest.Comment = Encoding.ASCII.GetBytes(TestSuiteBase.DisplayNameAndCommentForNonSearchFolder + "\0");

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

            this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                createFolderRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)this.response;
            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                createFolderResponse.ReturnValue,
                "if ROP succeeds, the ReturnValue of its response is 0(success)");
            uint targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
            tableHandle = this.GetContentsTableHandle(targetFolderHandle);
            ulong folderId = createFolderResponse.FolderId;

            #endregion

            int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int maxRetryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int retryCount;
            bool needRetry = false;
            uint returnValue = 0;
            int loopcount = 50;
            List<ISerializable> multipleRopRequests = new List<ISerializable>();
            List<IDeserializable> multipleRopResponses = new List<IDeserializable>();
            List<uint> multipleInputObjects = new List<uint>();
            List<uint> multipleOutputObjects = new List<uint>();

            for (int i = 0; i < count; i++)
            {
                // If the RPC report error code reported by the following three ROP methods is 1726 (The remote procedure call failed), 
                // re-do the common steps of this case.
                if (returnValue == 1726)
                {
                    // Step 1: Create a message.
                    #region Create message
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
                    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));
                    logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);
                    #endregion

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

                    this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                        openFolderRequest,
                        this.inputObjHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse);
                    openFolderResponse = (RopOpenFolderResponse)this.response;

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

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

                    this.responseSOHs = this.cropsAdapter.ProcessSingleRop(
                        createFolderRequest,
                        openedFolderHandle,
                        ref this.response,
                        ref this.rawData,
                        RopResponseType.SuccessResponse);
                    createFolderResponse = (RopCreateFolderResponse)this.response;
                    Site.Assert.AreEqual<uint>(
                        TestSuiteBase.SuccessReturnValue,
                        createFolderResponse.ReturnValue,
                        "if ROP succeeds, the ReturnValue of its response is 0(success)");
                    targetFolderHandle = this.responseSOHs[0][openFolderResponse.OutputHandleIndex];
                    tableHandle = this.GetContentsTableHandle(targetFolderHandle);
                    folderId = createFolderResponse.FolderId;
                }

                // Step 1: Create a message.
                #region Create message

                createMessageRequest.FolderId = logonResponse.FolderIds[4];

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

                retryCount = maxRetryCount;
                do
                {
                    multipleRopRequests.Clear();
                    multipleRopResponses.Clear();
                    multipleOutputObjects.Clear();
                    multipleInputObjects.Clear();

                    // Send multiple RopCreateMessage to create messages.
                    for (int t = 0; t < loopcount; t++)
                    {
                        createMessageRequest.FolderId = folderId;
                        createMessageRequest.InputHandleIndex = 0;
                        createMessageRequest.OutputHandleIndex = Convert.ToByte(t + 1);
                        multipleRopRequests.Add(createMessageRequest);
                        if (t == 0)
                        {
                            multipleInputObjects.Add(this.inputObjHandle);
                        }
                        else
                        {
                            multipleInputObjects.Add(TestSuiteBase.DefaultFolderHandle);
                        }
                    }

                    // An additional default handle is needed since the output handle index is from 1 to t+1 in the above loop, and the last one is not added in the above loop.
                    multipleInputObjects.Add(TestSuiteBase.DefaultFolderHandle);

                    this.responseSOHs = this.cropsAdapter.ProcessMutipleRops(
                      multipleRopRequests,
                      multipleInputObjects,
                      ref multipleRopResponses,
                      ref this.rawData,
                      RopResponseType.SuccessResponse);

                    for (int t = 0; t < multipleRopResponses.Count; t++)
                    {
                        if (multipleRopResponses[t] is RopBackoffResponse)
                        {
                            needRetry = true;
                            break;
                        }
                    }

                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while (needRetry && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }

                for (int t = 0; t < multipleRopResponses.Count; t++)
                {
                    if (multipleRopResponses[t] is RopCreateMessageResponse)
                    {
                        createMessageResponse = (RopCreateMessageResponse)multipleRopResponses[t];
                        Site.Assert.AreEqual<uint>(
                            TestSuiteBase.SuccessReturnValue,
                            createMessageResponse.ReturnValue,
                            "if ROP succeeds, the ReturnValue of its response is 0(success)");
                        uint targetMessageHandle = this.responseSOHs[0][createMessageResponse.OutputHandleIndex];
                        multipleOutputObjects.Add(targetMessageHandle);
                    }
                }
                #endregion

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

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

                needRetry = false;
                retryCount = maxRetryCount;

                do
                {
                    multipleRopRequests.Clear();
                    multipleRopResponses.Clear();

                    // Send multiple RopSaveChangesMessage requests to save the created messages.
                    for (int t = 0; t < loopcount; t++)
                    {
                        saveChangesMessageRequest.InputHandleIndex = Convert.ToByte(t);
                        multipleRopRequests.Add(saveChangesMessageRequest);
                    }

                    this.responseSOHs = this.cropsAdapter.ProcessMutipleRops(
                     multipleRopRequests,
                     multipleOutputObjects,
                     ref multipleRopResponses,
                     ref this.rawData,
                     RopResponseType.SuccessResponse);

                    for (int t = 0; t < multipleRopResponses.Count; t++)
                    {
                        if (multipleRopResponses[t] is RopSaveChangesMessageResponse)
                        {
                            saveChangesMessageResponse = (RopSaveChangesMessageResponse)multipleRopResponses[t];
                            if (saveChangesMessageResponse.ReturnValue == 0x80040401)
                            {
                                needRetry = true;
                                break;
                            }
                        }
                        else if (this.response is RopBackoffResponse)
                        {
                            needRetry = false;
                            break;
                        }
                    }

                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while (this.response is RopBackoffResponse && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }

                for (int t = 0; t < multipleRopResponses.Count; t++)
                {
                    if (multipleRopResponses[t] is RopSaveChangesMessageResponse)
                    {
                        saveChangesMessageResponse = (RopSaveChangesMessageResponse)multipleRopResponses[t];
                        Site.Assert.AreEqual<uint>(
                            TestSuiteBase.SuccessReturnValue,
                            saveChangesMessageResponse.ReturnValue,
                        "if ROP succeeds, the ReturnValue of its response is 0(success)");
                    }
                }

                #endregion

                // Step 3: Send the RopRelease request to release all resources associated with a Server object.
                #region Release all resources

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 2:Begin to send the RopRelease request in CreateVastMessages method.");
                needRetry = false;
                retryCount = maxRetryCount;

                do
                {
                    multipleRopRequests.Clear();
                    multipleRopResponses.Clear();
                    for (int t = 0; t < loopcount; t++)
                    {
                        releaseRequest.InputHandleIndex = Convert.ToByte(t);
                        multipleRopRequests.Add(releaseRequest);
                    }

                    this.responseSOHs = this.cropsAdapter.ProcessMutipleRops(
                     multipleRopRequests,
                     multipleOutputObjects,
                     ref multipleRopResponses,
                     ref this.rawData,
                     RopResponseType.SuccessResponse);

                    if (multipleRopResponses.Count != 0)
                    {
                        for (int t = 0; t < multipleRopResponses.Count; t++)
                        {
                            if (multipleRopResponses[t] is RopBackoffResponse)
                            {
                                needRetry = true;
                                break;
                            }
                        }
                    }

                    System.Threading.Thread.Sleep(waitTime);
                    retryCount--;
                }
                while (needRetry && retryCount >= 0);

                Site.Assert.IsTrue(retryCount >= 0, "The case {0} failed since server is busy, reduce your server load and try again.", this.TestContext.TestName);

                // If the error code is 1726, continue this loop.
                if (returnValue == 1726)
                {
                    continue;
                }
                #endregion
            }

            // If the error code 1726 occurs on the last time of the above "for" loop, re-do the common steps.
            if (returnValue == 1726)
            {
                #region The common steps
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "If RPC error code is 1726, re-connect to server.");
                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));
                logonResponse = this.Logon(LogonType.Mailbox, this.userDN, out this.inputObjHandle);
                #endregion
            }
        }
        public void MSOXCROPS_S04_TC05_TestRopOpenAndDeleteAttachment()
        {
            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: Create and save message.
            #region Create and save message

            // Log on to the 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

            // Save message.
            #region Save message

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;

            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.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.
            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

            #endregion

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

            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 2: 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];
            uint attachmentId = createAttachmentResponse.AttachmentID;

            #endregion

            // Step 3: Send the RopSaveChangesAttachment request and verify the success response.
            #region RopSaveChangesAttachment success response

            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 3: 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

            // Step 4: Send the RopGetPropertiesAll request and verify the success response.
            #region RopGetPropertiesAll success response

            RopGetPropertiesAllRequest getPropertiesAllRequest;
            RopGetPropertiesAllResponse getPropertiesAllResponse;

            getPropertiesAllRequest.RopId = (byte)RopId.RopGetPropertiesAll;

            getPropertiesAllRequest.LogonId = TestSuiteBase.LogonId;
            getPropertiesAllRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set PropertySizeLimit, which specifies the maximum size allowed for a property value returned.
            getPropertiesAllRequest.PropertySizeLimit = TestSuiteBase.PropertySizeLimit;

            getPropertiesAllRequest.WantUnicode = (ushort)Zero;

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

            // Send the RopGetPropertiesAll request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getPropertiesAllRequest,
                attachmentHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getPropertiesAllResponse = (RopGetPropertiesAllResponse)response;

            Site.Assert.AreEqual<uint>(
                TestSuiteBase.SuccessReturnValue,
                getPropertiesAllResponse.ReturnValue,
                "if ROP succeeds, ReturnValue of its response will be 0 (success)");

            int counter = 0;
            byte[] tempArray = BitConverter.GetBytes(attachmentId);
            foreach (TaggedPropertyValue item in getPropertiesAllResponse.PropertyValues)
            {
                // Refer to MS-OXPROPS, the Property ID of PidTagAttachNumber is 0x0E21.
                if (item.PropertyTag.PropertyId == 0x0E21)
                {
                    if (item.Value == null || tempArray == null)
                    {
                        break;
                    }
                    else if (item.Value.Length == 0 || tempArray.Length == 0)
                    {
                        break;
                    }
                    else if (item.Value.Length != tempArray.Length)
                    {
                        break;
                    }
                    else
                    {
                        for (int i = 0; i < tempArray.Length; i++)
                        {
                            if (item.Value[i] == tempArray[i])
                            {
                                counter++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    break;
                }
            }

            bool isVerifyR2175 = counter == tempArray.Length;

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R2175
            Site.CaptureRequirementIfIsTrue(
                isVerifyR2175,
                2175,
                @"[In RopCreateAttachment ROP Success Response Buffer,AttachmentID (4 bytes)] The value of this field is equivalent to the value of the PidTagAttachNumber property ([MS-OXCMSG] section 2.2.2.6).");
            #endregion

            // Step 5: Send the RopSaveChangesAttachment request and verify the success response.
            #region RopOpenAttachment success response

            RopOpenAttachmentRequest openAttachmentRequest;
            RopOpenAttachmentResponse openAttachmentResponse;

            openAttachmentRequest.RopId = (byte)RopId.RopOpenAttachment;
            openAttachmentRequest.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.
            openAttachmentRequest.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.
            openAttachmentRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            openAttachmentRequest.OpenAttachmentFlags = (byte)OpenAttachmentFlags.ReadOnly;

            // Set AttachmentID, which identifies the attachment to be opened.
            openAttachmentRequest.AttachmentID = attachmentId;

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

            // Send the RopOpenAttachment request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                openAttachmentRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            openAttachmentResponse = (RopOpenAttachmentResponse)response;

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

            #endregion

            // Step 6: Send the RopSaveChangesAttachment request and verify the success response.
            #region  RopDeleteAttachment success response

            RopDeleteAttachmentRequest deleteAttachmentRequest;
            RopDeleteAttachmentResponse deleteAttachmentResponse;

            deleteAttachmentRequest.RopId = (byte)RopId.RopDeleteAttachment;
            deleteAttachmentRequest.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.
            deleteAttachmentRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set AttachmentID, which e identifies the attachment to be deleted.
            deleteAttachmentRequest.AttachmentID = attachmentId;

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

            // Send the RopDeleteAttachment request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                deleteAttachmentRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            deleteAttachmentResponse = (RopDeleteAttachmentResponse)response;

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

            #endregion

            // Step 7: Send the RopCreateAttachment request and verify the failure response.
            #region RopCreateAttachment failure response

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

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

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

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

            #endregion
        }
Пример #27
0
        /// <summary>
        /// Prepare the ROP request for RopCreateMessage, RopSaveChangesMessage and RopRelease.
        /// </summary>
        /// <param name="logonResponse">The response of RopLogon.</param>
        /// <param name="createMessageRequest">The request of RopCreateMessage.</param>
        /// <param name="saveChangesMessageRequest">The request of RopSaveChangesMessage.</param>
        /// <param name="releaseRequest">The request of RopRelease.</param>
        protected void PrepareRops(RopLogonResponse logonResponse, ref RopCreateMessageRequest createMessageRequest, ref RopSaveChangesMessageRequest saveChangesMessageRequest, ref RopReleaseRequest releaseRequest)
        {
            #region prepare rops for createmessage, savemessage and release
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId = TestSuiteBase.LogonId;
            createMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            createMessageRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

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

            createMessageRequest.FolderId = logonResponse.FolderIds[4];
            createMessageRequest.AssociatedFlag = Convert.ToByte(TestSuiteBase.Zero);

            // Save message 
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = TestSuiteBase.LogonId;
            saveChangesMessageRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            saveChangesMessageRequest.ResponseHandleIndex = TestSuiteBase.ResponseHandleIndex1;
            saveChangesMessageRequest.SaveFlags = (byte)SaveFlags.ForceSave;

            releaseRequest.RopId = (byte)RopId.RopRelease;
            releaseRequest.LogonId = TestSuiteBase.LogonId;
            releaseRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;
            #endregion        
        }
        public void MSOXCROPS_S04_TC06_TestRopGetAttachmentTableAndGetValidAttachments()
        {
            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 and save message, then create and save attachment.
            #region Create and save message, create and save attachment

            // 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 4th of logonResponse, 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

            // Save 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 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 an attachment to above message.
            #region Create an 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 the attachment.
            #region Save the 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

            // Refer to MS-OXCMSG: Exchange 2010 and Exchange 2013 do not support the RopGetValidAttachments ROP.
            if (Common.IsRequirementEnabled(171501, this.Site))
            {
                // Step 2: Send the RopGetValidAttachments request to the server and verify the success response.
                #region RopGetValidAttachmentsRequest success response

                RopGetValidAttachmentsRequest getValidAttachmentsRequest;
                RopGetValidAttachmentsResponse getValidAttachmentsResponse;

                getValidAttachmentsRequest.RopId = (byte)RopId.RopGetValidAttachments;
                getValidAttachmentsRequest.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.
                getValidAttachmentsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

                // Send the RopGetValidAttachments request and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    getValidAttachmentsRequest,
                    targetMessageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                getValidAttachmentsResponse = (RopGetValidAttachmentsResponse)response;

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

                // Verify MS-OXCROPS requirement: MS-OXCROPS_R071501
                Site.CaptureRequirementIfAreEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    getValidAttachmentsResponse.ReturnValue,
                    171501,
                    @"[In Appendix A: Product Behavior] Implementation does support the RopgetValidAttachments ROP. (Exchange 2007 follows this behavior.)");

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

                #endregion

                // Step 3: Send the RopGetValidAttachments request to the server and verify the failure response.
                #region RopGetValidAttachments failure response

                getValidAttachmentsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

                // Send the RopGetValidAttachments request and verify the failure response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    getValidAttachmentsRequest,
                    targetMessageHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.FailureResponse);
                getValidAttachmentsResponse = (RopGetValidAttachmentsResponse)response;

                Site.Assert.AreNotEqual<uint>(
                    TestSuiteBase.SuccessReturnValue,
                    getValidAttachmentsResponse.ReturnValue,
                    "if ROP failure, the ReturnValue of its response is not 0(failure)");

                #endregion
            }

            // Step 4: Send the RopGetAttachmentTable request to the server and verify the success response.
            #region RopGetAttachmentTable response

            RopGetAttachmentTableRequest getAttachmentTableRequest;
            RopGetAttachmentTableResponse getAttachmentTableResponse;

            getAttachmentTableRequest.RopId = (byte)RopId.RopGetAttachmentTable;
            getAttachmentTableRequest.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.
            getAttachmentTableRequest.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.
            getAttachmentTableRequest.OutputHandleIndex = TestSuiteBase.OutputHandleIndex1;

            getAttachmentTableRequest.TableFlags = (byte)MsgTableFlags.Standard;

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

            // Send the RopGetAttachmentTable request and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getAttachmentTableRequest,
                targetMessageHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getAttachmentTableResponse = (RopGetAttachmentTableResponse)response;

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

            #endregion
        }
Пример #29
0
        /// <summary>
        /// Create and save message.
        /// </summary>
        /// <param name="folderHandle">Folder Handle </param>
        /// <param name="folderId">Folder Id  which messages will be create in.</param>
        /// <param name="associatedFlag">Specifies whether the message is a Folder Associated Information message.</param>
        /// <param name="messageId"> Message Id which will be returned by server.</param>
        /// <param name="messageHandle">Message Handle which will be returned by server.</param>
        protected void CreateSaveMessage(uint folderHandle, ulong folderId, byte associatedFlag, ref ulong messageId, ref uint messageHandle)
        {
            // Create a Message.
            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest();
            RopCreateMessageResponse createMessageResponse = new RopCreateMessageResponse();
            object ropResponse = null;
            createMessageRequest.RopId = (byte)RopId.RopCreateMessage;
            createMessageRequest.LogonId = Constants.CommonLogonId;
            createMessageRequest.InputHandleIndex = Constants.CommonInputHandleIndex;
            createMessageRequest.OutputHandleIndex = Constants.CommonOutputHandleIndex;
            createMessageRequest.CodePageId = 0x0FFF;
            createMessageRequest.FolderId = folderId;
            createMessageRequest.AssociatedFlag = associatedFlag;
            this.Adapter.DoRopCall(createMessageRequest, folderHandle, ref ropResponse, ref this.responseHandles);

            createMessageResponse = (RopCreateMessageResponse)ropResponse;
            Site.Assert.AreEqual<uint>(0, createMessageResponse.ReturnValue, "Creating Message should succeed");
            messageHandle = this.responseHandles[0][createMessageResponse.OutputHandleIndex];

            // Save a Message.
            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest();
            RopSaveChangesMessageResponse saveChangesMessageResponse = new RopSaveChangesMessageResponse();
            saveChangesMessageRequest.RopId = (byte)RopId.RopSaveChangesMessage;
            saveChangesMessageRequest.LogonId = Constants.CommonLogonId;
            saveChangesMessageRequest.InputHandleIndex = Constants.CommonInputHandleIndex;
            saveChangesMessageRequest.ResponseHandleIndex = 0x01;
            saveChangesMessageRequest.SaveFlags = 0x0C;
            this.Adapter.DoRopCall(saveChangesMessageRequest, messageHandle, ref ropResponse, ref this.responseHandles);

            saveChangesMessageResponse = (RopSaveChangesMessageResponse)ropResponse;
            Site.Assert.AreEqual<uint>(
                0,
                createMessageResponse.ReturnValue,
                "Save Messages Success.");
            messageId = saveChangesMessageResponse.MessageId;
        }
        public void MSOXCROPS_S05_TC08_TestRopTransportNewMail()
        {
            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: Send the RopSetSpooler request and verify the success response.
            #region RopSetSpooler response

            RopSetSpoolerRequest setSpoolerRequest;
            RopSetSpoolerResponse setSpoolerResponse;

            setSpoolerRequest.RopId = (byte)RopId.RopSetSpooler;
            
            setSpoolerRequest.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.
            setSpoolerRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

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

            // Send the RopSetSpooler request to the server and verify the success response.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setSpoolerRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            setSpoolerResponse = (RopSetSpoolerResponse)response;

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

            #endregion

            if (Common.IsRequirementEnabled(1772, this.Site))
            {
                // Step 2: Create, modify recipients and save message.
                #region Create, modify recipients and save message

                // Create a message
                #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 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 2: 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

                // Configure recipients
                #region Configure 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 recipientColumns to null, which means no property values are included for each recipient.
                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 3: 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 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 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 4: 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 messageId = saveChangesMessageResponse.MessageId;

                #endregion

                #endregion

                // Step 3: Send the RopTransportNewMail request and verify the success response.
                #region RopTransportNewMail response with the field MessageFlags value is MfRead

                RopTransportNewMailRequest transportNewMailRequest;
                RopTransportNewMailResponse transportNewMailResponse;

                transportNewMailRequest.RopId = (byte)RopId.RopTransportNewMail;
                transportNewMailRequest.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.
                transportNewMailRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

                // Set MessageId to that of created message, which identifies the new Message object.
                transportNewMailRequest.MessageId = messageId;

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

                // Set MessageClass, which specifies the message class of the new Message object.
                transportNewMailRequest.MessageClass = Encoding.ASCII.GetBytes(TestSuiteBase.MessageClassForRopTransportNewMail + "\0");

                transportNewMailRequest.MessageFlags = (byte)MessageFlags.MfRead;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopTransportNewMail request the field MessageFlags value is MfRead.");

                // Send the RopTransportNewMail request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    transportNewMailRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                transportNewMailResponse = (RopTransportNewMailResponse)response;

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

                #endregion

                #region RopTransportNewMail response with the field MessageFlags value is MfUnsent

                transportNewMailRequest.MessageFlags = (byte)MessageFlags.MfUnsent;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopTransportNewMail request the field MessageFlags value is MfUnsent.");

                // Send the RopTransportNewMail request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    transportNewMailRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                transportNewMailResponse = (RopTransportNewMailResponse)response;

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

                #endregion

                #region RopTransportNewMail response with the field MessageFlags value is MfResend

                transportNewMailRequest.MessageFlags = (byte)MessageFlags.MfResend;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Step 5: Begin to send the RopTransportNewMail request the field MessageFlags value is MfResend.");

                // Send the RopTransportNewMail request to the server and verify the success response.
                this.responseSOHs = cropsAdapter.ProcessSingleRop(
                    transportNewMailRequest,
                    this.inputObjHandle,
                    ref this.response,
                    ref this.rawData,
                    RopResponseType.SuccessResponse);
                transportNewMailResponse = (RopTransportNewMailResponse)response;

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

                #endregion
            }
        }