Microsoft.Protocols.TestSuites.MS_OXORULE.MS_OXORULEAdapter.VerifyRopGetPropertiesAllForExtendedRules C# (CSharp) Method

VerifyRopGetPropertiesAllForExtendedRules() private method

Verify the RopGetPropertiesAll operation performed on extended rules.
private VerifyRopGetPropertiesAllForExtendedRules ( RopGetPropertiesAllResponse ropGetPropertiesAllResponse ) : void
ropGetPropertiesAllResponse Microsoft.Protocols.TestSuites.Common.RopGetPropertiesAllResponse RopGetPropertiesAll response buffer.
return void
        private void VerifyRopGetPropertiesAllForExtendedRules(RopGetPropertiesAllResponse ropGetPropertiesAllResponse)
        {
            // isFAIMessage indicates whether the current message is an FAI Message.
            bool isFAIMessage = false;

            // PidTagRuleMessageNameValue indicates the property value of PidTagRuleMessageName.
            string pidTagRuleMessageNameValue = null;

            // PidTagMessageClassValue indicates the property value of PidTagMessageClass.
            string pidTagMessageClassValue = null;

            // PidTagRuleMessageSequenceValue indicates the property value of PidTagRuleMessageSequence.
            byte[] pidTagRuleMessageSequenceValue = null;

            // PidTagRuleMessageStateValue indicates the property value of PidTagRuleMessageState.
            byte[] pidTagRuleMessageStateValue = null;

            // PidTagRuleMessageUserFlagsValue indicates the property value of PidTagRuleMessageUserFlags.
            byte[] pidTagRuleMessageUserFlagsValue = null;

            // PidTagRuleMessageLevelValue indicates the property value of PidTagRuleMessageLevel.
            byte[] pidTagRuleMessageLevelValue = null;

            // PidTagRuleMessageProviderValue indicates the property value of PidTagRuleMessageProvider.
            string pidTagRuleMessageProviderValue = null;

            // PidTagRuleMessageProviderDataValue indicates the property value of PidTagRuleMessageProviderData.
            byte[] pidTagRuleMessageProviderDataValue = null;

            // PidTagExtendedRuleMessageActionsValue indicates the property value of PidTagExtendedRuleMessageActions.
            ExtendedRuleActions pidTagExtendedRuleMessageActionsValue = null;

            // PidTagExtendedRuleMessageConditionValue indicates the property value of PidTagExtendedRuleMessageCondition.
            ExtendedRuleCondition pidTagExtendedRuleMessageConditionValue = null;

            // ropGetPropertiesAllResponse.PropertyValues contains a list of properties set on a Message.
            for (int i = 0; i < ropGetPropertiesAllResponse.PropertyValues.Length; i++)
            {
                // propertyId indicates the Id of a property.
                ushort propertyId = ropGetPropertiesAllResponse.PropertyValues[i].PropertyTag.PropertyId;

                // propertyType indicates the Type of a property.
                ushort propertyType = ropGetPropertiesAllResponse.PropertyValues[i].PropertyTag.PropertyType;

                // propertyValue indicates the value of a property.
                byte[] propertyValue = ropGetPropertiesAllResponse.PropertyValues[i].Value;

                switch (propertyId)
                {
                    // If propertyId is 0x001A, it means the property is PidTagMessageClass.
                    case 0x001A:
                        {
                            // Save the property value of PidTagMessageClass.
                            pidTagMessageClassValue = AdapterHelper.PropertyValueConvertToString(propertyValue);

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R167.
                            Site.CaptureRequirementIfAreEqual<string>(
                                "IPM.ExtendedRule.Message",
                                pidTagMessageClassValue,
                                167,
                                @"[In PidTagMessageClass Property] The PidTagMessageClass property ([MS-OXCMSG] section 2.2.1.3) MUST have a value of ""IPM.ExtendedRule.Message"".");

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R165.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypString,
                                propertyType,
                                165,
                                @"[In PidTagMessageClass Property] Type: PtypString ([MS-OXCDATA] section 2.11.1).");
                        }

                        break;

                    // If propertyId is 0x65EC, it means the property is PidTagRuleMessageName.
                    case 0x65EC:
                        {
                            // Save the property value of PidTagRuleMessageName.
                            pidTagRuleMessageNameValue = AdapterHelper.PropertyValueConvertToString(propertyValue);

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R161.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypString,
                                propertyType,
                                161,
                                @"[In PidTagRuleMessageName Property] Type: PtypString ([MS-OXCDATA] section 2.11.1).");

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

                            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2700.
                            bool isVerifyR2700 = Common.IsUtf16LEString(propertyValue) && propertyType == 0x001F;

                            Site.CaptureRequirementIfIsTrue(
                                isVerifyR2700,
                                "MS-OXCDATA",
                                2700,
                                @"[In Property Data Types] PtypString (PT_UNICODE, string) is that Variable size; a string of Unicode characters in UTF-16LE format encoding with terminating null character (0x0000). with Property Type Value  0x001F,%x1F.00.");
                        }

                        break;

                    // If propertyId is 0x65F3, it means the property is PidTagRuleMessageSequence.
                    case 0x65F3:
                        {
                            // Save the property value of PidTagRuleMessageSequence.
                            pidTagRuleMessageSequenceValue = propertyValue;

                            // Add the debug information.
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2691, the propertyValue.Length should be 4 and the actual value is {0}, the propertyType of this property should be 0x0003 and the actual value is {1}.", propertyValue.Length, propertyType);

                            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2691.
                            bool isVerifyR2691 = propertyValue.Length == 4 && propertyType == 0x0003;

                            Site.CaptureRequirementIfIsTrue(
                                isVerifyR2691,
                                "MS-OXCDATA",
                                2691,
                                @"[In Property Data Types] PtypInteger32 (PT_LONG, PT_I4, int, ui4) is that 4 bytes; a 32-bit integer [MS-DTYP]: INT32 with Property Type Value 0x0003,%x03.00.");

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R168.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypInteger32,
                                propertyType,
                                168,
                                @"[In PidTagRuleMessageSequence Property] Type: PtypInteger32 ([MS-OXCDATA] section 2.11.1).");
                        }

                        break;

                    // If propertyId is 0x65E9, it means the property is PidTagRuleMessageState.
                    case 0x65E9:
                        {
                            // Save the property value of PidTagRuleMessageState.
                            pidTagRuleMessageStateValue = propertyValue;

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R171.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypInteger32,
                                propertyType,
                                171,
                                @"[In PidTagRuleMessageState Property] Type: PtypInteger32 ([MS-OXCDATA] section 2.11.1).");
                        }

                        break;

                    // If propertyId is 0x65ED, it means the property is PidTagRuleMessageLevel.
                    case 0x65ED:
                        {
                            // Save the property value of PidTagRuleMessageLevel.
                            pidTagRuleMessageLevelValue = propertyValue;

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R178.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypInteger32,
                                propertyType,
                                178,
                                @"[In PidTagRuleMessageLevel Property] Type: PtypInteger32 ([MS-OXCDATA] section 2.11.1).");
                        }

                        break;

                    // If propertyId is 0x65EB, it means the property is PidTagRuleMessageProvider.
                    case 0x65EB:
                        {
                            // Save the property value of PidTagRuleMessageProvider.
                            pidTagRuleMessageProviderValue = AdapterHelper.PropertyValueConvertToString(propertyValue);

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R182.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypString,
                                propertyType,
                                182,
                                @"[In PidTagRuleMessageProvider Property] Type: PtypString ([MS-OXCDATA] section 2.11.1).");
                        }

                        break;

                    // If propertyId is 0x0E99, it means the property is PidTagExtendedRuleMessageActions.
                    case 0x0E99:
                        {
                            // Save the property value of PidTagExtendedRuleMessageActions.
                            pidTagExtendedRuleMessageActionsValue = AdapterHelper.PropertyValueConvertToExtendedRuleActions(propertyValue);

                            // Add the debug information.
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2707, the COUNT value({0}) of the propertyValue should equal to the propertyValue.Length({1}) - 2, and the propertyType({2}) of the property should be 0x0102.", BitConverter.ToInt16(propertyValue, 0), propertyValue.Length, propertyType);

                            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2707.
                            bool isVerifyR2707 = BitConverter.ToInt16(propertyValue, 0) == propertyValue.Length - 2 && propertyType == 0x0102;

                            Site.CaptureRequirementIfIsTrue(
                                isVerifyR2707,
                                "MS-OXCDATA",
                                2707,
                                @"[In Property Data Types] PtypBinary (PT_BINARY) is that variable size; a COUNT field followed by that many bytes with Property Type Value 0x0102,%x02.01.");

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R189.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypBinary,
                                propertyType,
                                189,
                                @"[In PidTagExtendedRuleMessageActions Property] Type: PtypBinary ([MS-OXCDATA] section 2.11.1).");

                            // Verify the ExtendedRuleActions structure related requirements.
                            this.VerifyExtendedRuleMessageActions(pidTagExtendedRuleMessageActionsValue);
                        }

                        break;

                    // If propertyId is 0x0E9A, it means the property is PidTagExtendedRuleMessageCondition.
                    case 0x0E9A:
                        {
                            // Save the property value of PidTagExtendedRuleMessageCondition.
                            pidTagExtendedRuleMessageConditionValue = AdapterHelper.PropertyValueConvertToExtendedRuleCondition(propertyValue);

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

                            // Verify MS-OXORULE requirement: MS-OXORULE_R195.
                            Site.CaptureRequirementIfAreEqual<ushort>(
                                (ushort)PropertyType.PtypBinary,
                                propertyType,
                                195,
                                @"[In PidTagExtendedRuleMessageCondition Property] Type: PtypBinary ([MS-OXCDATA] section 2.11.1).");

                            // Verify the ExtendedRuleCondition structure related requirements.
                            this.VerifyExtendedRuleMessageCondition(pidTagExtendedRuleMessageConditionValue);
                        }

                        break;

                    // If propertyId is 0x0E07, it means the property is PidTagMessageFlags.
                    case 0x0E07:
                        {
                            // If mfFAI flag is set on the property value of PidTagMessageFlags, it means this message is an FAI message.
                            if ((AdapterHelper.PropertyValueConvertToInt(propertyValue) & (uint)PidTagMessageFlag.mfFAI) == (uint)PidTagMessageFlag.mfFAI)
                            {
                                isFAIMessage = true;
                            }
                        }

                        break;
                }
            }

            // isFAIMessage indicates whether the current message is an FAI message.
            if (isFAIMessage)
            {
                if (Common.IsRequirementEnabled(894, this.Site))
                {
                    // Add the debug information.
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R894.");

                    // Verify MS-OXORULE requirement: MS-OXORULE_R894.
                    // The current message is an FAI message. If the property value of PidTagRuleMessageName is not null, it means this property is set on FAI message.
                    Site.CaptureRequirementIfIsNotNull(
                        pidTagRuleMessageNameValue,
                        894,
                        @"[In PidTagRuleMessageName Property] The implementation does set the PidTagRuleMessageName property ([MS-OXPROPS] section 2.942)  on the FAI message. (Exchange 2003 and above follow this behavior.)");
                }

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R166.
                // The current message is an FAI message. If the property value of PidTagMessageClass is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagMessageClassValue,
                    166,
                    @"[In PidTagMessageClass Property] The PidTagMessageClass property ([MS-OXCMSG] section 2.2.1.3) MUST be set on the FAI message.");

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R169.
                // The current message is an FAI message. If the property value of PidTagRuleMessageSequence is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagRuleMessageSequenceValue,
                    169,
                    @"[In PidTagRuleMessageSequence Property] The PidTagRuleMessageSequence property ([MS-OXPROPS] section 2.947) MUST be set on the FAI message.");

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R172.
                // The current message is an FAI message. If the property value of PidTagRuleMessageState is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagRuleMessageStateValue,
                    172,
                    @"[In PidTagRuleMessageState Property] The PidTagRuleMessageState property ([MS-OXPROPS] section 2.948) MUST be set on the FAI message.");

                if (Common.IsRequirementEnabled(891, this.Site))
                {
                    // Add the debug information.
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R891, the property value of the PidTagRuleMessageUserFlags is {0}.", pidTagRuleMessageUserFlagsValue);

                    // Verify MS-OXORULE requirement: MS-OXORULE_R891.
                    Site.CaptureRequirementIfIsNull(
                        pidTagRuleMessageUserFlagsValue,
                        891,
                        @"[In PidTagRuleMessageUserFlags Property] The implementation does not set the PidTagRuleMessageUserFlags property ([MS-OXPROPS] section 2.947) on the FAI message. (Exchange 2003 and above follow this behavior.)");
                }

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

                    // Verify MS-OXORULE requirement: MS-OXORULE_R892.
                    // The current message is an FAI message. If the property value of PidTagRuleMessageLevel is not null, it means this property is not set on FAI message.
                    Site.CaptureRequirementIfIsNotNull(
                        pidTagRuleMessageLevelValue,
                        892,
                        @"[In PidTagRuleMessageLevel Property] The implementation does set the PidTagRuleMessageLevel property ([MS-OXPROPS] section 2.941) on the FAI message. (Exchange 2003 and above follow this behavior.)");
                }

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R183.
                // The current message is an FAI message. If the property value of PidTagRuleMessageProvider is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagRuleMessageProviderValue,
                    183,
                    @"[In PidTagRuleMessageProvider Property] The PidTagRuleMessageProvider property ([MS-OXPROPS] section 2.945) MUST be set on the FAI message.");

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

                    // Verify MS-OXORULE requirement: MS-OXORULE_R893.
                    // The current message is an FAI message. If the property value of PidTagRuleMessageProviderData is null, it means this property is not set on FAI message.
                    Site.CaptureRequirementIfIsNull(
                        pidTagRuleMessageProviderDataValue,
                        893,
                        @"[In PidTagRuleMessageProviderData Property] The implementation does not set the PidTagRuleMessageProviderData property ([MS-OXPROPS] section 2.943) on the FAI message. (Exchange 2003 and above follow this behavior.)");
                }

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R190.
                // The current message is an FAI message. If the property value of PidTagExtendedRuleMessageActions is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagExtendedRuleMessageActionsValue,
                    190,
                    @"[In PidTagExtendedRuleMessageActions Property] The PidTagExtendedRuleMessageActions property ([MS-OXPROPS] section 2.683) MUST be set on the FAI message.");

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

                // Verify MS-OXORULE requirement: MS-OXORULE_R196.
                // The current message is an FAI message. If the property value of PidTagExtendedRuleMessageCondition is not null, it means this property is set on FAI message.
                Site.CaptureRequirementIfIsNotNull(
                    pidTagExtendedRuleMessageConditionValue,
                    196,
                    @"[In PidTagExtendedRuleMessageCondition Property] The PidTagExtendedRuleMessageCondition property ([MS-OXPROPS] section 2.684) MUST be set on the FAI message.");
            }
        }