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

MSOXCRPC_S01_TC08_TestROPReadStream() private method

private MSOXCRPC_S01_TC08_TestROPReadStream ( ) : void
return void
        public void MSOXCRPC_S01_TC08_TestROPReadStream()
        {
            this.CheckTransport();

            #region Client connects with Server
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                null,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);
            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoConnectEx should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion

            #region Logon to mailbox
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopLogon, this.unusedInfo, this.userPrivilege);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.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);
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][logonResponse.OutputHandleIndex];
            #endregion

            #region RopCreateMessage
            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 this.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, "RopCreateMessage should succeed, the ReturnValue of its response is expected to be 0(success). The returned value is {0}.", createMessageResponse.ReturnValue);
            uint messageHandle = this.responseSOHTable[TestSuiteBase.FIRST][createMessageResponse.OutputHandleIndex];
            #endregion

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

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.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, "RopOpenStream should succeed, the ReturnValue of its response is expected to be 0(success). The returned value is {0}.", openStreamResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][openStreamResponse.OutputHandleIndex];
            #endregion

            #region RopWriteStream
            RopWriteStreamResponse writeStreamResponse;
            for (int i = 0; i < int.Parse(Common.GetConfigurationPropertyValue("WriteStreamCount", this.Site)); i++)
            {
                // Parameter auxInfo is no use for RopWriteStream command, so set it to unUsedInfo
                this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopWriteStream, this.objHandle, this.unusedInfo);
                this.pcbOut = ConstValues.ValidpcbOut;
                this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
                this.responseSOHTable = new List<List<uint>>();

                this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                    ref this.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, "RopWriteStream should succeed, the ReturnValue of its response is expected to be 0(success). The returned value is {0}.", writeStreamResponse.ReturnValue);
            }
            #endregion

            #region RopCommitStream
            // Parameter auxInfo is no use for RopCommitStream command, so set it to unUsedInfo
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopCommitStream, this.objHandle, this.unusedInfo);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.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, "RopCommitStream should succeed, the ReturnValue of its response is expected to be 0(success). The returned value is {0}.", commitStreamResponse.ReturnValue);
            #endregion

            #region RopOpenStream
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopOpenStream, messageHandle, (ulong)ZERO); // Open the new committed stream for read-only access
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.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 for RopOpenStream and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            openStreamResponse = (RopOpenStreamResponse)this.response;
            Site.Assert.AreEqual<uint>(0, openStreamResponse.ReturnValue, "RopOpenStream should succeed for RopOpenStream and '0' is expected to be returned. The returned value is {0}.", openStreamResponse.ReturnValue);
            this.objHandle = this.responseSOHTable[TestSuiteBase.FIRST][openStreamResponse.OutputHandleIndex];
            #endregion

            #region RopReadStream with requested small data
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopReadStream, this.objHandle, ConstValues.RequestedByteCount);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();

            this.returnValue = this.oxcrpcAdapter.EcDoRpcExt2(
                ref this.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 for small requested data 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>(0, readStreamResponse.ReturnValue, "RopReadStream for small requested data should succeed and '0' is expected to be returned. The returned value is {0}.", readStreamResponse.ReturnValue);

            // Add the debug information 
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R972, the data size that server returned is {0}, the data size that client requested is {1}.", readStreamResponse.DataSize, ConstValues.RequestedByteCount);

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R972
            Site.CaptureRequirementIfIsTrue(
                readStreamResponse.DataSize <= ConstValues.RequestedByteCount,
                972,
                @"[In Extended Buffer Packing]The server MUST NOT return more data to the client than the client originally requested.");

            #endregion

            #region RopReadStream with requested large enough data
            // An unsigned long indicates a value of maximumByteCount value in RopReadStream request, as specified by RopReadStream ROP in [MS-OXCROPS].
            ulong maximumByteWithLargeData = 327680;
            this.rgbIn = AdapterHelper.ComposeRgbIn(ROPCommandType.RopReadStream, this.objHandle, maximumByteWithLargeData);
            this.pcbOut = ConstValues.ValidpcbOut;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.responseSOHTable = new List<List<uint>>();
            uint payloadCount = 0;

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

            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoRpcExt2 for small requested data should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            readStreamResponse = (RopReadStreamResponse)this.response;
            Site.Assert.AreEqual<uint>(0, readStreamResponse.ReturnValue, "RopReadStream for small requested data should succeed and '0' is expected to be returned. The returned value is {0}.", readStreamResponse.ReturnValue);

            this.ServerAddAdditionalData(payloadCount);

            #endregion

            #region Client disconnects with Server
            this.returnValue = this.oxcrpcAdapter.EcDoDisconnect(ref this.pcxh);
            Site.Assert.AreEqual<uint>(0, this.returnValue, "EcDoDisconnect should succeed and '0' is expected to be returned. The returned value is {0}.", this.returnValue);
            #endregion
        }