Microsoft.Protocols.TestSuites.MS_OXCRPC.S01_SynchronousCall.TryRopReadStream C# (CSharp) Method

TryRopReadStream() private method

If server version equals to or greater than 8.0.295.0, server supports passing the sentinel value 0xBABE in the ByteCount field of a RopReadStream request.
private TryRopReadStream ( IntPtr pcxh ) : bool
pcxh System.IntPtr A unique value to be used as a session context handle.
return bool
        private bool TryRopReadStream(IntPtr pcxh)
        {
            #region Logon
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopLogon, 0, (ulong)OpenFlags.UsePerMDBReplipMapping);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);
            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            RopLogonResponse logonResponse = (RopLogonResponse)this.response;
            Site.Assert.AreEqual<uint>(0, logonResponse.ReturnValue, "RopLogon should succeed and 0 is expected to be returned. The returned value is {0}.", logonResponse.ReturnValue);

            // The element whose index is 0 indicates this ROP command response handle
            this.objHandle = this.responseSOHTable[0][logonResponse.OutputHandleIndex];
            #endregion

            #region CreateMessage
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopCreateMessage, this.objHandle, logonResponse.FolderIds[(int)FolderIds.Inbox]);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            RopCreateMessageResponse createMessageResponse = (RopCreateMessageResponse)this.response;
            Site.Assert.AreEqual<uint>(
                0x00000000,
                createMessageResponse.ReturnValue,
                "If RopCreateMessage succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                createMessageResponse.ReturnValue);
            uint messageHandle = this.responseSOHTable[0][createMessageResponse.OutputHandleIndex];
            #endregion

            #region OpenStream
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopOpenStream, messageHandle, (ulong)StreamOpenModeFlags.Create);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            RopOpenStreamResponse openStreamResponse = (RopOpenStreamResponse)this.response;
            Site.Assert.AreEqual<uint>(
                0x00000000,
                openStreamResponse.ReturnValue,
               "If RopOpenStream succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                openStreamResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[0][openStreamResponse.OutputHandleIndex];
            #endregion

            #region RopWriteStream
            RopWriteStreamResponse writeStreamResponse;
            int writeCount = Convert.ToInt32(Common.GetConfigurationPropertyValue("WriteStreamCount", Site));
            for (int counter = 0; counter < writeCount; counter++)
            {
                // auxInfo is not used for RopWriteSteam, so set it to 0
                this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopWriteStream, this.objHandle, 0);
                this.pcbOut = ConstValues.ValidpcbOut;
                this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
                this.responseSOHTable = new List<List<uint>>();

                this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                    ref pcxh,
                    PulFlags.NoCompression | PulFlags.NoXorMagic,
                    this.rgbIn,
                    ref this.pcbOut,
                    null,
                    ref this.pcbAuxOut,
                    out this.response,
                    ref this.responseSOHTable);

                Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
                writeStreamResponse = (RopWriteStreamResponse)this.response;

                Site.Assert.AreEqual<uint>(
                    0x00000000,
                    writeStreamResponse.ReturnValue,
                    "If RopWriteStream succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                    writeStreamResponse.ReturnValue);
            }
            #endregion

            #region RopCommitStream
            // auxInfo is not used for RopCommitSteam, so set it to 0
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopCommitStream, this.objHandle, 0);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            RopCommitStreamResponse commitStreamResponse = (RopCommitStreamResponse)this.response;

            Site.Assert.AreEqual<uint>(
                0x00000000,
                commitStreamResponse.ReturnValue,
                "If RopCommitStream succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                commitStreamResponse.ReturnValue);
            #endregion

            #region OpenStream
            // OpenModeFlags is set to 0 means ReadOnly.
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopOpenStream, messageHandle, 0);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            openStreamResponse = (RopOpenStreamResponse)this.response;
            Site.Assert.AreEqual<uint>(
                0x00000000,
                openStreamResponse.ReturnValue,
                "If RopOpenStream succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                openStreamResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[0][openStreamResponse.OutputHandleIndex];
            #endregion

            #region ReadStream
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopReadStream, this.objHandle, ConstValues.MaximumByteCountIndicator);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref pcxh,
                PulFlags.NoCompression | PulFlags.NoXorMagic | PulFlags.Chain,
                this.rgbIn,
                ref this.pcbOut,
                null,
                ref this.pcbAuxOut,
                out this.response,
                ref this.responseSOHTable);

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 should succeed and 0 is expected to be returned. The returned value is {0}.", this.returnValue);
            RopReadStreamResponse readStreamResponse = (RopReadStreamResponse)this.response;
            Site.Assert.AreEqual<uint>(
                0x00000000,
                readStreamResponse.ReturnValue,
                "If RopReadStream succeeds, the ReturnValue of its response is 0(success). Now the returned value is {0}.",
                readStreamResponse.ReturnValue);
            #endregion
            return readStreamResponse.ReturnValue == 0;
        }