Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.S02_RequestTypesForAddressBookServerEndpoint.MSOXCMAPIHTTP_S02_TC16_GetProps C# (CSharp) Method

MSOXCMAPIHTTP_S02_TC16_GetProps() private method

private MSOXCMAPIHTTP_S02_TC16_GetProps ( ) : void
return void
        public void MSOXCMAPIHTTP_S02_TC16_GetProps()
        {
            this.CheckMapiHttpIsSupported();

            #region Call Bind request type to established a session context with the address book server.
            this.Bind();
            #endregion

            #region Call UpdateStat to update the STAT block to make CurrentRec point to the first row of the table.
            STAT stat = new STAT();
            stat.InitiateStat();
            UpdateStatRequestBody updateStatRequestBody = this.BuildUpdateStatRequestBody(true, stat, true);

            UpdateStatResponseBody updateStatResponseBody = this.Adapter.UpdateStat(updateStatRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, updateStatResponseBody.ErrorCode, "UpdateStat operation should succeed and 0 is expected to be returned. The return value is {0}.", updateStatResponseBody.ErrorCode);
            #endregion

            #region Call GetProps request type with Flags set to fEphID.
            LargePropertyTagArray largePropTagArray = new LargePropertyTagArray();
            largePropTagArray.PropertyTagCount = 1;

            // PidTagDisplayName property.
            PropertyTag[] propertyTags = new PropertyTag[1];
            propertyTags[0].PropertyId = (ushort)PropertyID.PidTagDisplayName;
            propertyTags[0].PropertyType = (ushort)PropertyTypeValues.PtypString;
            largePropTagArray.PropertyTags = propertyTags;

            GetPropsRequestBody getPropertyRequestBody = this.BuildGetPropsRequestBody((uint)RetrievePropertyFlags.fEphID, true, updateStatResponseBody.State, true, largePropTagArray);
            GetPropsResponseBody getPropertyResponseBody = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody.ErrorCode, "GetProps operation should succeed and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody.ErrorCode);

            AddressBookTaggedPropertyValue[] propertyValues = getPropertyResponseBody.PropertyValues.Value.PropertyValues;

            bool isVerifiedR624 = false;

            if (getPropertyResponseBody.PropertyValues.Value.PropertyValueCount != largePropTagArray.PropertyTagCount)
            {
                isVerifiedR624 = false;
            }
            else
            {
                for (int i = 0; i < getPropertyResponseBody.PropertyValues.Value.PropertyValueCount; i++)
                {
                    if (propertyValues[i].PropertyId == propertyTags[i].PropertyId && propertyValues[i].PropertyType == propertyTags[i].PropertyType)
                    {
                        isVerifiedR624 = true;
                    }
                    else
                    {
                        isVerifiedR624 = false;
                        break;
                    }
                }
            }

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R624. The returned property numbers is {0}.", getPropertyResponseBody.PropertyValues.Value.PropertyValueCount);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R624
            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR624,
                624,
                @"[In GetProps Request Type Success Response Body] PropertyValues (optional) (variable): An AddressBookPropertyValueList structure (section 2.2.1.1) that contains the values of the properties requested.");

            // Add the debug information
            this.Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-OXCMAPIHTTP_R590. The returned property number is {0}, the returned property ID is {1}, the returned property type is {2}.",
                getPropertyResponseBody.PropertyValues.Value.PropertyValueCount,
                propertyValues[0].PropertyId,
                propertyValues[0].PropertyType);
            #endregion

            #region Call GetProps request type with Flags set to fSkipObjects.
            getPropertyRequestBody = this.BuildGetPropsRequestBody((uint)RetrievePropertyFlags.fSkipObjects, true, updateStatResponseBody.State, true, largePropTagArray);
            getPropertyResponseBody = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody.ErrorCode, "GetProps operation should succeed and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody.ErrorCode);
            #endregion

            #region Call GetProps request type with Flags set to one value other than fEphID (0x2) and fSkipObjects (0x1).
            uint flags1 = 0x0;
            getPropertyRequestBody = this.BuildGetPropsRequestBody(flags1, true, updateStatResponseBody.State, true, largePropTagArray);
            GetPropsResponseBody getPropertyResponseBody1 = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody1.ErrorCode, "GetProps operation should succeed and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody1.ErrorCode);
            #endregion

            #region Call GetProps request type with Flags set to one value other than fEphID (0x2) and fSkipObjects (0x1).
            uint flags2 = 0x8;
            getPropertyRequestBody = this.BuildGetPropsRequestBody(flags2, true, updateStatResponseBody.State, true, largePropTagArray);
            GetPropsResponseBody getPropertyResponseBody2 = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody2.ErrorCode, "GetProps operation should succeed and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody2.ErrorCode);

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

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1323
            this.Site.CaptureRequirementIfIsTrue(
                AdapterHelper.AreTwoAddressBookPropValueListEqual(getPropertyResponseBody1.PropertyValues.Value, getPropertyResponseBody2.PropertyValues.Value),
                1323,
                @"[In GetProps Request Type Request Body] If this field [Flags] is set to different values other than the bit flags fEphID (0x00000002) and fSkipObjects (0x00000001), the server will return the same result.");
            #endregion

            #region Call GetProps request type with setting fields HasState and HasPropertyTags to false.
            getPropertyRequestBody = this.BuildGetPropsRequestBody((uint)RetrievePropertyFlags.fEphID, false, updateStatResponseBody.State, false, largePropTagArray);
            getPropertyResponseBody = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody.StatusCode, "GetProps request should be executed successfully and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody.StatusCode);
            #endregion

            #region Call GetProps request type with HasState field set to false and HasPropertyTags set to true.
            getPropertyRequestBody = this.BuildGetPropsRequestBody((uint)RetrievePropertyFlags.fEphID, false, updateStatResponseBody.State, true, largePropTagArray);
            getPropertyResponseBody = this.Adapter.GetProps(getPropertyRequestBody);
            Site.Assert.AreEqual<uint>((uint)0, getPropertyResponseBody.StatusCode, "GetProps request should be executed successfully and 0 is expected to be returned. The return value is {0}.", getPropertyResponseBody.StatusCode);
            #endregion

            #region Call GetProps request type with Flags set to fEphID.
            largePropTagArray = new LargePropertyTagArray();
            largePropTagArray.PropertyTagCount = 2;

            // PidTagDisplayName property.
            propertyTags = new PropertyTag[2];
            propertyTags[0].PropertyId = (ushort)PropertyID.PidTagDisplayName;
            propertyTags[0].PropertyType = (ushort)PropertyTypeValues.PtypString;
            propertyTags[1].PropertyId = (ushort)PropertyID.PidTagAddressBookMember;
            propertyTags[1].PropertyType = (ushort)PropertyTypeValues.PtypEmbeddedTable;
            largePropTagArray.PropertyTags = propertyTags;

            getPropertyRequestBody = this.BuildGetPropsRequestBody((uint)RetrievePropertyFlags.fEphID, true, updateStatResponseBody.State, true, largePropTagArray);
            uint responseCodeHeader = 0;
            getPropertyResponseBody = this.Adapter.GetProps(getPropertyRequestBody, out responseCodeHeader);

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

                // Verify MS-OXCDATA requirement: MS-OXCMAPIHTTP_R2237
                this.Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    responseCodeHeader,
                    2237,
                    @"[In Appendix A: Product Behavior] If the type of the returned property is PtypObject or PtypEmbeddedTable ([MS-OXCDATA] section 2.11.1), implementation will return value 1 for the X-ResponseCode header.  (Exchange 2013 SP1 follows this behavior.)");
            }
            #endregion

            #region Call the Unbind request type to destroy the session context.
            this.Unbind();
            #endregion
        }