Microsoft.Protocols.TestSuites.MS_OXORULE.TestSuiteBase.CheckUnexpectedMessageExist C# (CSharp) Method

CheckUnexpectedMessageExist() protected method

Check if an unexpected message with a specific property value exists in the target mailbox.
protected CheckUnexpectedMessageExist ( uint folderHandle, uint &contentsTableHandle, PropertyTag propertyTagList, string unexpectedPropertyValue, PropertyId propertyName = PropertyId.PidTagSubject ) : bool
folderHandle uint Handle of a specific folder.
contentsTableHandle uint Handle of a specific contents table.
propertyTagList Microsoft.Protocols.TestSuites.Common.PropertyTag >Array of PropertyTag structures. This field specifies the property values that are visible in table rows.
unexpectedPropertyValue string The value of a specific property of the message to be checked in the target mailbox.
propertyName Microsoft.Protocols.TestSuites.Common.PropertyId The property name of a specific property of the message to be checked in the target mailbox, which type should be string. The default property name is PidTagSubject.
return bool
        protected bool CheckUnexpectedMessageExist(uint folderHandle, ref uint contentsTableHandle, PropertyTag[] propertyTagList, string unexpectedPropertyValue, PropertyId propertyName = PropertyId.PidTagSubject)
        {
            bool doesUnexpectedMessageExist = false;
            bool isExpectedPropertyInPropertyList = false;
            RopGetContentsTableResponse ropGetContentTableResponse = this.OxoruleAdapter.RopGetContentsTable(folderHandle, ContentTableFlag.None, out contentsTableHandle);
            Site.Assert.AreEqual<uint>(0, ropGetContentTableResponse.ReturnValue, "Getting contents table should succeed.");

            RopQueryRowsResponse getNormalMailMessageContent = this.OxoruleAdapter.QueryPropertiesInTable(contentsTableHandle, propertyTagList);
            Site.Assert.AreEqual<uint>(0, getNormalMailMessageContent.ReturnValue, "Getting mail message operation should succeed.");
            if (getNormalMailMessageContent.RowData.Count > 0)
            {
                for (int i = 0; i < propertyTagList.Length; i++)
                {
                    if (propertyTagList[i].PropertyId == (ushort)propertyName)
                    {
                        isExpectedPropertyInPropertyList = true;
                        for (int j = 0; j < getNormalMailMessageContent.RowData.PropertyRows.Count; j++)
                        {
                            string propertyValue = AdapterHelper.PropertyValueConvertToString(getNormalMailMessageContent.RowData.PropertyRows[j].PropertyValues[i].Value);
                            Site.Log.Add(LogEntryKind.Debug, "The value of the {0} property of the No.{1} message is : {2}", propertyName.ToString(), j + 1, propertyValue);
                            if (propertyValue.Contains(unexpectedPropertyValue))
                            {
                                doesUnexpectedMessageExist = true;
                                return doesUnexpectedMessageExist;
                            }
                        }
                    }
                }

                Site.Assert.IsTrue(isExpectedPropertyInPropertyList, "The property {0} to be checked should be included in the property list.", propertyName.ToString());
            }

            return doesUnexpectedMessageExist;
        }