コード例 #1
0
        /// <summary>
        /// This method is used to verify requirements gathered from MS-OXCDATA.
        /// </summary>
        /// <param name="recipientRows">ReadRecipientRow structure.</param>
        private void TestMSOXCDATARequirements(ReadRecipientRow[] recipientRows)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R177. The DisplayName is {0}.", recipientRows[0].RecipientRow.DisplayName);

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R177
            Site.CaptureRequirementIfAreEqual<int>(
                recipientRows[0].RecipientRow.RecipientColumnCount,
                recipientRows[0].RecipientRow.RecipientProperties.PropertyValues.Count,
                CdataShortName,
                177,
                @"[In RecipientRow] RecipientColumnCount (2 bytes): This value [RecipientColumnCount] specifies the number of columns from the RecipientColumns field that are included in the RecipientProperties field.");

            bool isFieldRExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0080);

            if (isFieldRExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R105. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R105
                // R flag exists if RecipientFlags & 0x0080 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    105,
                    @"[In RecipientFlags Field] R (1 bit): (mask 0x0080).");
            }

            bool isFieldSExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0040);

            if (isFieldSExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R107. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R107
                // S flag exists if RecipientFlags & 0x0040 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    107,
                    @"[In RecipientFlags Field] S (1 bit): (mask 0x0040).");
            }

            bool isFieldDExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0010);

            if (isFieldDExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R111. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R111
                // D flag exists if RecipientFlags & 0x0010 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    111,
                    @"[In RecipientFlags Field] D (1 bit): (mask 0x0010).");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R112. The DisplayName is {0}.", recipientRows[0].RecipientRow.DisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R112
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.DisplayName,
                    CdataShortName,
                    112,
                    @"[In RecipientFlags Field] D (1 bit): If this flag is b'1', the DisplayName field is included.");
                
                int lengthOfDisplayName = recipientRows[0].RecipientRow.DisplayName.Length;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R164. The DisplayName is {0}.", recipientRows[0].RecipientRow.DisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R164
                Site.CaptureRequirementIfAreEqual<ushort>(
                    0,
                    recipientRows[0].RecipientRow.DisplayName[lengthOfDisplayName - 1],
                    CdataShortName,
                    164,
                    @"[In RecipientRow Structure] DisplayName (optional) (variable): A null-terminated string.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R165. The DisplayName is {0}.", recipientRows[0].RecipientRow.DisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R165
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.DisplayName,
                    CdataShortName,
                    165,
                    @"[In RecipientRow Structure] DisplayName (optional) (variable): This field [DisplayName (optional) (variable)] MUST be present when the D flag of the RecipientsFlags field is set.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R166. The DisplayName is {0}.", recipientRows[0].RecipientRow.DisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R166
                bool isVerifiedR166 = Common.IsUtf16LEString(recipientRows[0].RecipientRow.DisplayName);
                Site.CaptureRequirementIfIsTrue(
                    isVerifiedR166,
                    CdataShortName,
                    166,
                    @"[In RecipientRow Structure] DisplayName (optional) (variable): This field [DisplayName] MUST be specified in Unicode characters if the U flag of the RecipientsFlags field is set and in the 8-bit character.");
            }

            bool isFieldEExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0008);

            if (isFieldEExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R113. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R113
                // E flag exists if RecipientFlags & 0x0008 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    113,
                    @"[In RecipientFlags Field] E (1 bit): (mask 0x0008).");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R114. The EmailAddress is {0}.", recipientRows[0].RecipientRow.EmailAddress);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R112
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.EmailAddress,
                    CdataShortName,
                    114,
                    @"[In RecipientFlags Field] E (1 bit): If this flag is b'1', the EmailAddress field is included.");

                 int lengthOfEmailAddress = recipientRows[0].RecipientRow.EmailAddress.Length;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R160. The EmailAddress is {0}.", recipientRows[0].RecipientRow.EmailAddress);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R160
                Site.CaptureRequirementIfAreEqual<ushort>(
                    0,
                    recipientRows[0].RecipientRow.EmailAddress[lengthOfEmailAddress - 1],
                    CdataShortName,
                    160,
                    @"[In RecipientRow Structure] EmailAddress (optional) (variable): A null-terminated string.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R161. The EmailAddress is {0}.", recipientRows[0].RecipientRow.EmailAddress);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R161
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.EmailAddress,
                    CdataShortName,
                    161,
                    @"[In RecipientRow Structure] EmailAddress (optional) (variable): This field [EmailAddress (optional) (variable)] MUST be present when the E flag of the RecipientsFlags field is set.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R162. The EmailAddress is {0}.", recipientRows[0].RecipientRow.EmailAddress);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R162
                bool isVerifiedR162 = Common.IsUtf16LEString(recipientRows[0].RecipientRow.EmailAddress);
                Site.CaptureRequirementIfIsTrue(
                    isVerifiedR162,
                    CdataShortName,
                    162,
                    @"[In RecipientRow Structure] EmailAddress (optional) (variable): This field MUST be specified in Unicode characters if the U flag of the RecipientsFlags field is set and in the 8-bit character set.");
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R115. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R115
            bool isFieldTypeExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0007);

            Site.CaptureRequirementIfIsTrue(
                isFieldTypeExist,
                CdataShortName,
                115,
                @"[In RecipientFlags Field] Type (3 bits): (mask 0x0007).");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R117. The value of Type is {0}.", (int)recipientRows[0].RecipientRow.RecipientFlags & 0x0007);

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R117
            int valueOfTypeField = (int)recipientRows[0].RecipientRow.RecipientFlags & 0x0007;
            bool isTypeValid = (valueOfTypeField & 0x0) == 0x0
                || (valueOfTypeField & 0x1) == 0x1
                || (valueOfTypeField & 0x2) == 0x2
                || (valueOfTypeField & 0x3) == 0x3
                || (valueOfTypeField & 0x4) == 0x4
                || (valueOfTypeField & 0x5) == 0x5
                || (valueOfTypeField & 0x6) == 0x6
                || (valueOfTypeField & 0x7) == 0x7;

            Site.CaptureRequirementIfIsTrue(
                isTypeValid,
                CdataShortName,
                117,
                @"[In  RecipientFlags Field] Type (3 bits):The valid types are: [NoType (0x0), X500DN (0x1), MsMail (0x2), SMTP (0x3), Fax (0x4), ProfessionalOfficeSystem (0x5), PersonalDistributionList1 (0x6), PersonalDistributionList2 (0x7)].");

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

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R108
            Site.CaptureRequirementIfAreEqual<int>(
                0x0000,
                (int)recipientRows[0].RecipientRow.RecipientFlags & 0x7800,
                CdataShortName,
                120,
                @"[In  RecipientFlags Field] Reserved (4 bits):  (mask 0x7800) The server MUST set this to b'0000'.");

            bool isFieldIExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0400);

            if (isFieldIExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R121. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R121
                // I flag exists if RecipientFlags & 0x0400 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    121,
                    @"[In  RecipientFlags Field] I (1 bit): (mask 0x0400).");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R122. The SimpleDisplayName is {0}.", recipientRows[0].RecipientRow.SimpleDisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R122
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.SimpleDisplayName,
                    CdataShortName,
                    122,
                    @"[In RecipientFlags Field] I (1 bit): If this flag is b'1', the SimpleDisplayName field is included.");

                  int lengthOfSimpleDisplayName = recipientRows[0].RecipientRow.SimpleDisplayName.Length;

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R168. The SimpleDisplayName is {0}.", recipientRows[0].RecipientRow.SimpleDisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R168
                Site.CaptureRequirementIfAreEqual<ushort>(
                    0,
                    recipientRows[0].RecipientRow.SimpleDisplayName[lengthOfSimpleDisplayName - 1],
                    CdataShortName,
                    168,
                    @"[In RecipientRow Structure] SimpleDisplayName (optional) (variable): A null-terminated string.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R169. The SimpleDisplayName is {0}.", recipientRows[0].RecipientRow.SimpleDisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R169
                Site.CaptureRequirementIfIsNotNull(
                    recipientRows[0].RecipientRow.SimpleDisplayName,
                    CdataShortName,
                    169,
                    @"[In RecipientRow Structure] SimpleDisplayName (optional) (variable): This field [SimpleDisplayName (optional) (variable)] MUST be present when the I flag of the RecipientsFlags field is set.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R170. The SimpleDisplayName is {0}.", recipientRows[0].RecipientRow.SimpleDisplayName);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R170
                bool isVerifiedR170 = Common.IsUtf16LEString(recipientRows[0].RecipientRow.SimpleDisplayName);
                Site.CaptureRequirementIfIsTrue(
                    isVerifiedR170,
                    CdataShortName,
                    170,
                    @"[In RecipientRow Structure] SimpleDisplayName (optional) (variable): This field MUST be specified in Unicode characters if the U flag of the RecipientsFlags field is set and in the 8-bit character set.");
            }

            bool isFieldUExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x0200);

            if (isFieldUExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R123. The RecipientFlags is {0}.", recipientRows[0].RecipientRow.RecipientFlags);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R123
                // U flag exists if RecipientFlags & 0x0200 is not 0.
                Site.CaptureRequirement(
                    CdataShortName,
                    123,
                    @"[In  RecipientFlags Field] U (1 bit): (mask 0x0200).");
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R2764. The DisplayType is {0}.", recipientRows[0].RecipientRow.DisplayType);

            // Verify MS-OXCDATA requirement: MS-OXCDATA_R2764
            bool isDisplayTypeValid = (recipientRows[0].RecipientRow.DisplayType & 0x00) == 0x00
                || (recipientRows[0].RecipientRow.DisplayType & 0x01) == 0x01
                || (recipientRows[0].RecipientRow.DisplayType & 0x02) == 0x02
                || (recipientRows[0].RecipientRow.DisplayType & 0x03) == 0x03
                || (recipientRows[0].RecipientRow.DisplayType & 0x04) == 0x04
                || (recipientRows[0].RecipientRow.DisplayType & 0x05) == 0x05
                || (recipientRows[0].RecipientRow.DisplayType & 0x06) == 0x06;

            Site.CaptureRequirementIfIsTrue(
                isDisplayTypeValid,
                CdataShortName,
                2764,
                @"[In RecipientRow Structure] Valid values [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06] for this field [DisplayType (optional) (1 byte)] are specified in the following table.");

            if (((int)(recipientRows[0].RecipientRow.RecipientFlags & 0x0007) != 0x6) && ((int)(recipientRows[0].RecipientRow.RecipientFlags & 0x0007) != 0x7))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R142. The EntryIdSize is {0}.", recipientRows[0].RecipientRow.EntryIdSize);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R142
                Site.CaptureRequirementIfAreEqual<ushort>(
                    0,
                    recipientRows[0].RecipientRow.EntryIdSize,
                    CdataShortName,
                    142,
                    @"[In RecipientRow Structure] EntryIdSize (optional) (2 bytes): This field MUST NOT be present otherwise. This value specifies the size of the EntryID field.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R145. The EntryId is {0}.", recipientRows[0].RecipientRow.EntryId);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R145
                Site.CaptureRequirementIfIsNull(
                    recipientRows[0].RecipientRow.EntryId,
                    CdataShortName,
                    145,
                    @"[In RecipientRow Structure] EntryID (optional) (variable): This field [EntryID (optional) (variable)] MUST NOT be present otherwise.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R150. The SearchKeySize is {0}.", recipientRows[0].RecipientRow.SearchKeySize);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R150
                Site.CaptureRequirementIfAreEqual<ushort>(
                    0,
                    recipientRows[0].RecipientRow.SearchKeySize,
                    CdataShortName,
                    150,
                    @"[In RecipientRow Structure] SearchKeySize (optional) (2 bytes): This field MUST NOT be present otherwise. This value specifies the size of the SearchKey field.");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R153. The SearchKey is {0}.", recipientRows[0].RecipientRow.SearchKey);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R150
                Site.CaptureRequirementIfIsNull(
                    recipientRows[0].RecipientRow.SearchKey,
                    CdataShortName,
                    153,
                    @"[In RecipientRow Structure] SearchKey (optional) (variable): This field [SearchKey (optional) (variable)] MUST NOT be present otherwise.");
            }

            bool isFieldOExist = Convert.ToBoolean(recipientRows[0].RecipientRow.RecipientFlags & 0x8000);

            if (!((int)(recipientRows[0].RecipientRow.RecipientFlags & 0x0007) == 0x0) || !isFieldOExist)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCDATA_R158. The AddressType is {0}.", recipientRows[0].RecipientRow.AddressType);

                // Verify MS-OXCDATA requirement: MS-OXCDATA_R158
                Site.CaptureRequirementIfIsNull(
                    recipientRows[0].RecipientRow.AddressType,
                    CdataShortName,
                    158,
                    @"[In RecipientRow Structure] AddressType (optional) (variable):  This field [AddressType (optional) (variable)] MUST NOT be present otherwise.");
            }
        }