public void MSOXCROPS_S11_TC10_TestRopSetLocalReplicaMidsetDeleted()
        {
            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 RopGetLocalReplicaIds request.
            #region RopGetLocalReplicaIds response

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

            RopGetLocalReplicaIdsRequest getLocalReplicaIdsRequest;
            RopGetLocalReplicaIdsResponse getLocalReplicaIdsResponse;

            // Construct the RopGetLocalReplicaIds request.
            getLocalReplicaIdsRequest.RopId = (byte)RopId.RopGetLocalReplicaIds;
            
            getLocalReplicaIdsRequest.LogonId = TestSuiteBase.LogonId;
            getLocalReplicaIdsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex0;

            // Set IdCount, which specifies the number of IDs to reserve.
            getLocalReplicaIdsRequest.IdCount = 0x00000003;

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

            // Send the RopGetLocalReplicaIds request.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                getLocalReplicaIdsRequest,
                this.inputObjHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);
            getLocalReplicaIdsResponse = (RopGetLocalReplicaIdsResponse)response;

            #endregion

            // Step 2: Set LongTermIdRange.
            #region Set LongTermIdRange

            LongTermIdRange longTermIdRange = new LongTermIdRange();
            byte[] valueMax = new byte[24];
            byte[] valueMin = new byte[24];
            Array.Copy(getLocalReplicaIdsResponse.ReplGuid, 0, valueMax, 0, 16);
            Array.Copy(getLocalReplicaIdsResponse.ReplGuid, 0, valueMin, 0, 16);

            Array.Copy(getLocalReplicaIdsResponse.GlobalCount, 0, valueMin, 16, 6);
            Array.Copy(getLocalReplicaIdsResponse.GlobalCount, 0, valueMax, 16, 6);

            longTermIdRange.MaxLongTermId = valueMax;
            longTermIdRange.MinLongTermId = valueMin;

            LongTermIdRange[] longTermIdRanges = new LongTermIdRange[1];
            longTermIdRanges[0] = longTermIdRange;

            #endregion

            // Step 3: Open a folder and get its handle.
            #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 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 handle of opened folder, which will be used as input handle in RopCreateFolder.
            uint openedFolderHandle = responseSOHs[0][openFolderResponse.OutputHandleIndex];

            #endregion

            // Step 4: Send the RopSetLocalReplicaMidsetDeleted request.
            #region RopSetLocalReplicaMidsetDeleted response

            RopSetLocalReplicaMidsetDeletedRequest setLocalReplicaMidsetDeletedRequest = new RopSetLocalReplicaMidsetDeletedRequest
            {
                RopId = (byte)RopId.RopSetLocalReplicaMidsetDeleted,
                LogonId = TestSuiteBase.LogonId,
                InputHandleIndex = TestSuiteBase.InputHandleIndex0,
                DataSize = 52,
                LongTermIdRangeCount = 1,
                LongTermIdRanges = longTermIdRanges
            };

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

            // Send the RopSetLocalReplicaMidsetDeleted request.
            this.responseSOHs = cropsAdapter.ProcessSingleRop(
                setLocalReplicaMidsetDeletedRequest,
                openedFolderHandle,
                ref this.response,
                ref this.rawData,
                RopResponseType.SuccessResponse);

            // Test RopSetLocalReplicaMidsetDeleted failure response.
            getLocalReplicaIdsRequest.InputHandleIndex = TestSuiteBase.InputHandleIndex1;

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

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

            #endregion
        }
        /// <summary>
        /// Identifies that a set of IDs either belongs to deleted messages in the specified folder or will never be used for any messages in the specified folder.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="folderhandleIndex">A Folder object handle index.</param>
        /// <param name="longTermIdRangeIndex">An array of LongTermIdRange structures defines a range of IDs, which are reported as unused or deleted.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult SetLocalReplicaMidsetDeleted(int serverId, int folderhandleIndex, Sequence<int> longTermIdRangeIndex)
        {
            // Initialize ROP data.
            RopResult result = RopResult.InvalidParameter;
            uint folderHandle = this.handleContainer[folderhandleIndex];
            LongTermIdRange[] idranges = new LongTermIdRange[longTermIdRangeIndex.Count];

            // Get the Mid need to be deleted.
            for (int i = 0; i < longTermIdRangeIndex.Count; i++)
            {
                LongTermId max = new LongTermId();
                LongTermId min = new LongTermId();

                // Max Mid
                max.DatabaseGuid = this.serverReplicaGuid.ToByteArray();
                max.GlobalCounter = new byte[6];
                Array.Copy(this.localId, 0, max.GlobalCounter, 0, 6);
                byte[] sub = new byte[4];
                Array.Copy(max.GlobalCounter, 2, sub, 0, 4);
                Array.Reverse(sub);
                int num = BitConverter.ToInt32(sub, 0);

                // Make the Mid to the mid to be deleted one.
                num += longTermIdRangeIndex[i];
                sub = BitConverter.GetBytes(num);
                Array.Reverse(sub);
                Array.Copy(sub, 0, max.GlobalCounter, 2, 4);

                // Min Mid
                min.DatabaseGuid = this.serverReplicaGuid.ToByteArray();
                min.GlobalCounter = new byte[6];
                Array.Copy(this.localId, 0, min.GlobalCounter, 0, 6);
                sub = new byte[4];
                Array.Copy(min.GlobalCounter, 2, sub, 0, 4);
                Array.Reverse(sub);
                num = BitConverter.ToInt32(sub, 0);

                // Make the Mid to the mid to be deleted one.
                num += longTermIdRangeIndex[i];
                sub = BitConverter.GetBytes(num);
                Array.Reverse(sub);
                Array.Copy(sub, 0, min.GlobalCounter, 2, 4);

                // ID range data
                idranges[i].MaxLongTermId = max.Serialize();
                idranges[i].MinLongTermId = min.Serialize();
            }

            // Construct the RopGetLocalReplicaIds request.
            RopSetLocalReplicaMidsetDeletedRequest req = new RopSetLocalReplicaMidsetDeletedRequest
            {
                RopId = 0x93
            };
            byte logonId = 0;
            req.LogonId = logonId;
            req.InputHandleIndex = 0;
            req.DataSize = (ushort)((sizeof(byte) * 48 * idranges.Length) + 4);
            req.LongTermIdRangeCount = (uint)idranges.Length;

            // Set idCount, which specifies the number of IDs to reserve,
            req.LongTermIdRanges = idranges;

            // Send request and get response.
            RopSetLocalReplicaMidsetDeletedResponse setLocalReplicaMidsetDeletedResponse = (RopSetLocalReplicaMidsetDeletedResponse)this.Process(serverId, req, folderHandle);
            result = (RopResult)setLocalReplicaMidsetDeletedResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                // Verify ROP SetLocalReplicaMidsetDeleted
                this.VerifyRopSetLocalReplicaMidsetDeleted(setLocalReplicaMidsetDeletedResponse);
            }

            return result;
        }