/// <summary>
        /// This ROP opens a property for streaming access.
        /// </summary>
        /// <param name="objHandle">The handle to operate.</param>
        /// <param name="openStreamResponse">The response of this ROP.</param>
        /// <param name="tag">The propertyTag structure.</param>
        /// <param name="openMode">8-bit flags structure. These flags control how the stream is opened.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle returned.</returns>
        private uint RopOpenStream(uint objHandle, out RopOpenStreamResponse openStreamResponse, PropertyTag tag, byte openMode, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopOpenStreamRequest openStreamRequest;

            openStreamRequest.RopId = (byte)RopId.RopOpenStream;
            openStreamRequest.LogonId = LogonId;
            openStreamRequest.InputHandleIndex = (byte)HandleIndex.FirstIndex;
            openStreamRequest.OutputHandleIndex = (byte)HandleIndex.SecondIndex;
            openStreamRequest.PropertyTag = tag;
            openStreamRequest.OpenModeFlags = openMode;

            this.responseSOHsValue = this.ProcessSingleRop(openStreamRequest, objHandle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openStreamResponse = (RopOpenStreamResponse)this.responseValue;
            uint streamObjectHandle = this.responseSOHsValue[0][openStreamResponse.OutputHandleIndex];
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openStreamResponse.ReturnValue, string.Format("RopOpenStream Failed! Error: 0x{0:X8}", openStreamResponse.ReturnValue));
            }

            return streamObjectHandle;
        }
        /// <summary>
        /// Verify the RopOpenStream operation related requirements.
        /// </summary>
        /// <param name="ropOpenStreamResponse">The RopOpenStream response buffer structure.</param>
        /// <param name="objectType">Indicates which object type the RopOpenStream operation is acting on.</param>
        /// <param name="isPropertyTagExist">A boolean value indicates if the property tag exist for the object or not.</param>
        /// <param name="openFlag">Specifies OpenModeFlags for RopOpenStream.</param>
        private void VerifyRopOpenStream(RopOpenStreamResponse ropOpenStreamResponse, ServerObjectType objectType, bool isPropertyTagExist, OpenModeFlags openFlag)
        {
            if (!isPropertyTagExist && openFlag != OpenModeFlags.Create)
            {
                // Error code NotFound value is 0x8004010F
                bool isR891Satisfied = ropOpenStreamResponse.ReturnValue == 0x8004010F;
                if (isR891Satisfied)
                {
                    // The parser has ensured the field satisfied the format, otherwise the response cannot be received.
                    Site.CaptureRequirement(
                        "MS-OXCDATA",
                        2055,
                        @"[In Additional Error Codes] The numeric value (hex) for error code NotFound is 0x8004010F, %x0F.01.04.80.");
                }

                if (Common.IsRequirementEnabled(891, this.Site))
                {
                    // Verify MS-OXCPRPT requirement: MS-OXCPRPT_R891
                    Site.CaptureRequirementIfIsTrue(
                        isR891Satisfied,
                        891,
                        @"[In Processing RopOpenStream] Implementation does return error ""0x8004010F"" with name ""NotFound"", when The property tag does not exist for the object, and it cannot be created because the Create bit was not specified in OpenModeFlags field.(Microsoft Exchange Server 2007 and above follow this behavior)");
                }
            }
            else
            {
                // Since the RopOpenStream ROP response was parsed successfully, MS-OXCPRPT_R537 can be captured directly.
                Site.CaptureRequirement(
                    537,
                    @"[In Processing RopOpenStream] The server responds with a RopOpenStream ROP response buffer.");

                // If this operation is performed successfully, that means this operation opens a property as a Stream object.
                Site.CaptureRequirement(
                    251,
                    @"[In RopOpenStream ROP] The RopOpenStream ROP ([MS-OXCROPS] section 2.2.9.1) opens a property as a Stream object.");
                if (ropOpenStreamResponse.ReturnValue.Equals((uint)CPRPTErrorCode.None))
                {
                    if (objectType == ServerObjectType.Message)
                    {
                        // If the object type this operation acting on is Message object and this operation is performed successfully, then the following requirement can be captured.
                        Site.CaptureRequirement(
                            25301,
                            @"[In RopOpenStream ROP] This operation [RopOpenStream ROP] is valid on Message objects.");
                    }

                    if (objectType == ServerObjectType.Folder)
                    {
                        // If the object type this operation acting on is Folder object and this operation is performed successfully, then the following requirement can be captured.
                        Site.CaptureRequirement(
                            25302,
                            @"[In RopOpenStream ROP] This operation [RopOpenStream ROP] is valid on Folder objects.");
                    }

                    if (objectType == ServerObjectType.Attachment)
                    {
                        // If the object type this operation acting on is Attachment object and this operation is performed successfully, then the following requirement can be captured.
                        Site.CaptureRequirement(
                            25303,
                            @"[In RopOpenStream ROP] This operation [RopOpenStream ROP] is valid on Attachment objects.");
                    }

                    // If the OpenStream operation succeeds, it means the StreamSize filed has been set by server internally with the current number of BYTES in the stream.
                    // So this requirement can be verified directly. 
                    Site.CaptureRequirement(
                        276,
                        @"[In RopOpenStream ROP Response Buffer]StreamSize (4 bytes).");

                    // If the OpenStream operation succeeds, it means the StreamSize filed has been set by server internally with the current number of BYTES in the stream.
                    // So this requirement can be verified directly. 
                    Site.CaptureRequirement(
                       27601,
                       @"[In RopOpenStream ROP Response Buffer]StreamSize: An integer that specifies the number of bytes in the opened stream. ");
                }
            }
        }
        /// <summary>
        /// Verify RopOpenStream Failure Response
        /// </summary>
        /// <param name="ropOpenStreamResponse">The response of RopOpenStream failure request</param>
        /// <param name="outputHandleIndex">The field of OutputHandleIndex in RopOpenStream request</param>
        private void VerifyRopOpenStreamFailureResponse(RopOpenStreamResponse ropOpenStreamResponse, byte outputHandleIndex)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3186");

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3186
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropOpenStreamResponse.RopId.GetType(),
                3186,
                @"[In RopOpenStream ROP Failure Response Buffer]RopId (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3188
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)RopId.RopOpenStream,
                ropOpenStreamResponse.RopId,
                3188,
                @"[In RopOpenStream ROP Failure Response Buffer,RopId (1 byte)]For this operation[RopOpenStream], this field is set to 0x2B.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3189
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropOpenStreamResponse.OutputHandleIndex.GetType(),
                3189,
                @"[In RopOpenStream ROP Failure Response Buffer]OutputHandleIndex (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3190
            Site.CaptureRequirementIfAreEqual<byte>(
                outputHandleIndex,
                ropOpenStreamResponse.OutputHandleIndex,
                3190,
                @"[In RopOpenStream ROP Failure Response Buffer,OutputHandleIndex (1 byte)]This index MUST be set to the value specified in the OutputHandleIndex field in the request.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3192
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropOpenStreamResponse.ReturnValue.GetType(),
                3192,
                @"[In RopOpenStream ROP Failure Response Buffer]ReturnValue (4 bytes): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3194
            Site.CaptureRequirementIfAreNotEqual<uint>(
                SuccessReturnValue,
                ropOpenStreamResponse.ReturnValue,
                3194,
                @"[In Failure Response Buffer,ReturnValue (4 bytes)]For this response[Failure Response ], this
                field is set to a value other than 0x00000000.");
        }
        /// <summary>
        /// Verify RopOpenStream Success Response
        /// </summary>
        /// <param name="ropOpenStreamResponse">The success response of RopOpenStream request</param>
        /// <param name="outputHandleIndex">The field of OutputHandleIndex in RopOpenStream request</param>
        private void VerifyRopOpenStreamSuccessResponse(RopOpenStreamResponse ropOpenStreamResponse, byte outputHandleIndex)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3175");

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3175
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropOpenStreamResponse.RopId.GetType(),
                3175,
                @"[In RopOpenStream ROP Success Response Buffer]RopId (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3177
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)RopId.RopOpenStream,
                ropOpenStreamResponse.RopId,
                3177,
                @"[In RopOpenStream ROP Success Response Buffer,RopId (1 byte)]For this operation[RopOpenStream], this field is set to 0x2B.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3178
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(byte),
                ropOpenStreamResponse.OutputHandleIndex.GetType(),
                3178,
                @"[In RopOpenStream ROP Success Response Buffer]OutputHandleIndex (1 byte): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3179
            Site.CaptureRequirementIfAreEqual<byte>(
                outputHandleIndex,
                ropOpenStreamResponse.OutputHandleIndex,
                3179,
                @"[In RopOpenStream ROP Success Response Buffer,OutputHandleIndex (1 byte)]This index MUST be set to the value specified in the OutputHandleIndex field in the request.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3181
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropOpenStreamResponse.ReturnValue.GetType(),
                3181,
                @"[In RopOpenStream ROP Success Response Buffer]ReturnValue (4 bytes): An unsigned integer.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3183
            Site.CaptureRequirementIfAreEqual<uint>(
                SuccessReturnValue,
                ropOpenStreamResponse.ReturnValue,
                3183,
                @"[In RopOpenStream ROP Success Response Buffer,ReturnValue (4 bytes)]For this response[Success Response], this field is set to 0x00000000.");

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

            // Verify MS-OXCROPS requirement: MS-OXCROPS_R3184
            Site.CaptureRequirementIfAreEqual<Type>(
                typeof(uint),
                ropOpenStreamResponse.StreamSize.GetType(),
                3184,
                @"[In RopOpenStream ROP Success Response Buffer]StreamSize (4 bytes): An unsigned integer.");
        }