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

MSOXCRPC_S01_TC02_TestInvalidParameterForMethodEcDoConnectEx() private method

        public void MSOXCRPC_S01_TC02_TestInvalidParameterForMethodEcDoConnectEx()
        {
            this.CheckTransport();

            byte[] payload = AdapterHelper.Compose_AUX_PERF_SESSIONINFO(ReserveDefault);

            #region Client connects with Server when the client version is invalid
            // 0x1, 0x2, 0x3 are older values for rgwClientVersion than that required by the server.
            ushort[] rgwClientVersionTemp = new ushort[3] { 0x1, 0x2, 0x3 };
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                null,
                this.userDN,
                ref this.pcbAuxOut,
                rgwClientVersionTemp,
                out this.rgwBestVersion,
                out this.picxr);
            Site.Assert.AreNotEqual<uint>(0, this.returnValue, "EcDoConnectEx should fail when the client and server versions are not compatible and '0' isn't expected to be returned. The returned value is {0}.", this.returnValue);

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

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R483
            Site.CaptureRequirementIfAreEqual<IntPtr>(
                IntPtr.Zero,
                this.pcxh,
                483,
                @"[In EcDoConnectEx Method (Opnum 10)] [pcxh] On failure, the server MUST return a zero value as the session context handle.");

            #endregion

            #region Client connects with Server when cbAuxIn is equal to TooBigcbAuxIn
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.rgbAuxIn = new byte[ConstValues.TooBigcbAuxIn];
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                this.rgbAuxIn,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);

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

                // Verify MS-OXCRPC requirement: MS-OXCRPC_R4875
                // The condition that cbAuxIn is larger than 0x00001008 bytes is controlled by "TooBigcbAuxIn" because the value of "TooBigcbAuxIn" is defined as a constant with value "4105(0x1009)".
                Site.CaptureRequirementIfAreEqual<uint>(
                    0x000006F7,
                    this.returnValue,
                    4875,
                    @"[In Appendix B: Product Behavior] Implementation does fail with the RPC status code RPC_X_BAD_STUB_DATA (0x000006F7) if the value of cbAuxIn is larger than 0x00001008 bytes in size. (Exchange 2010 and above follow this behavior.)");
            }
            #endregion

            #region Client connects with Server when cbAuxIn is equal to TooSmallcbAuxIn
            this.pcxh = IntPtr.Zero;
            this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
            this.pulTimeStamp = 0;
            this.picxr = 0;
            this.rgbAuxIn = new byte[ConstValues.TooSmallcbAuxIn];
            Array.Copy(payload, this.rgbAuxIn, ConstValues.TooSmallcbAuxIn);
            this.returnValue = this.oxcrpcAdapter.EcDoConnectEx(
                ref this.pcxh,
                TestSuiteBase.UlIcxrLinkForNoSessionLink,
                ref this.pulTimeStamp,
                this.rgbAuxIn,
                this.userDN,
                ref this.pcbAuxOut,
                this.rgwClientVersion,
                out this.rgwBestVersion,
                out this.picxr);

            if (Common.IsRequirementEnabled(1436, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1436, the return value is {0}", this.returnValue);

                // Verify MS-OXCRPC requirement: MS-OXCRPC_R1436
                // The condition that cbAuxIn is less than 0x00000008 is controlled by constant "TooSmallcbAuxIn" defined in ConstValues.cs.
                int lengthOfcbAuxIn = this.rgbAuxIn.Length;
                bool isVerifyR1436 = (0x00000000 == this.returnValue) && (lengthOfcbAuxIn > 0x00000000 && lengthOfcbAuxIn < 0x00000008);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR1436,
                    1436,
                    @"[In Appendix B: Product Behavior] Implementation does not fail if cbAuxIn is greater than 0x00000000 and less than 0x00000008. <14> Section 3.1.4.1: Exchange 2007 does not fail if cbAuxIn is greater than 0x00000000 and less than 0x00000008.");
            }

            if (Common.IsRequirementEnabled(1940, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCRPC_R1940, the return value is {0}", this.returnValue);

                // Verify MS-OXCRPC requirement: MS-OXCRPC_R1940
                // The condition that cbAuxIn is less than 0x00000008 is controlled by constant "TooSmallcbAuxIn" defined in ConstValues.cs.
                int lengthOfcbAuxIn = this.rgbAuxIn.Length;
                bool isVerifyR1940 = (0x80040115 == this.returnValue) && (lengthOfcbAuxIn > 0x00000000 && lengthOfcbAuxIn < 0x00000008);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR1940,
                    1940,
                    @"[In Appendix B: Product Behavior] Implementation does fail with ecRpcFailed (0x80040115) if this value is greater than 0x00000000 and less than 0x00000008. (Microsoft Exchange Server 2010 and above follow this behavior.)");
            }
            #endregion

            #region Client connects with Server when pcbAuxOut is equal to TooBigpcbAuxOut
            this.pcxh = IntPtr.Zero;
            this.pcbAuxOut = ConstValues.TooBigpcbAuxOut;
            this.pulTimeStamp = 0;
            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);

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

            // Verify MS-OXCRPC requirement: MS-OXCRPC_R579
            // The condition that pcbAuxOut is larger than 0x00001008 bytes is controlled by constant "TooBigpcbAuxOut" defined in ConstValues.cs.
            Site.CaptureRequirementIfAreEqual<uint>(
                0x000006F7,
                this.returnValue,
                579,
                @"[In EcDoConnectEx Method (Opnum 10)] [pcbAuxOut] If this value on input is larger than 0x00001008, the server MUST fail with the RPC status code RPC_X_BAD_STUB_DATA (0x000006F7).");

            #endregion
        }