コード例 #1
0
        /// <summary>
        /// Check if an unexpected message with a specific property value exists in the target mailbox.
        /// </summary>
        /// <param name="folderHandle">Handle of a specific folder.</param>
        /// <param name="contentsTableHandle">Handle of a specific contents table.</param>
        /// <param name="propertyTagList">>Array of PropertyTag structures. This field specifies the property values that are visible in table rows.</param>
        /// <param name="unexpectedPropertyValue">The value of a specific property of the message to be checked in the target mailbox.</param>
        /// <param name="propertyName">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.</param>
        /// <returns>A bool value indicates whether a message with specific property value exists in the target mailbox. True means exist, otherwise not.</returns>
        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;
        }
コード例 #2
0
        /// <summary>
        /// Get the expected message properties included in a specific contents table after retry preconfigured times.
        /// </summary>
        /// <param name="folderHandle">Handle of a specific folder.</param>
        /// <param name="contentsTableHandle">Handle of a specific contents table.</param>
        /// <param name="propertyTagList">>Array of PropertyTag structures. This field specifies the property values that are visible in table rows.</param>
        /// <param name="expectedMessageIndex">The index of the specific message in the table.</param>
        /// <param name="expectedPropertyValue">The value of a specific property of the message to be found in the target mailbox.</param>
        /// <param name="expectedPropertyName">The property name of a specific property of the message to be found in the target mailbox, which type should be string. The default property name is PidTagSubject.</param>
        /// <returns>Response of the RopQueryRow ROP contents the expected message properties.</returns>
        protected RopQueryRowsResponse GetExpectedMessage(uint folderHandle, ref uint contentsTableHandle, PropertyTag[] propertyTagList, ref int expectedMessageIndex, string expectedPropertyValue, PropertyId expectedPropertyName = PropertyId.PidTagSubject)
        {
            RopQueryRowsResponse getNormalMailMessageContent = new RopQueryRowsResponse();
            uint repeatTime = 0;
            uint rowCount = 0;
            bool isExpectedPropertyInPropertyList = false;

            // If retry time more than expected, terminates the loop
            while (repeatTime < this.getMessageRepeatTime)
            {
                RopGetContentsTableResponse ropGetContentsTableResponse = this.OxoruleAdapter.RopGetContentsTable(folderHandle, ContentTableFlag.None, out contentsTableHandle);
                Site.Assert.AreEqual<uint>(0, ropGetContentsTableResponse.ReturnValue, "Getting contents table should succeed.");
                rowCount = ropGetContentsTableResponse.RowCount;
                repeatTime++;

                if (rowCount > 0)
                {
                    getNormalMailMessageContent = this.OxoruleAdapter.QueryPropertiesInTable(contentsTableHandle, propertyTagList);
                    Site.Assert.AreEqual<uint>(0, getNormalMailMessageContent.ReturnValue, "Getting mail message operation should succeed.");

                    for (int i = 0; i < propertyTagList.Length; i++)
                    {
                        if (propertyTagList[i].PropertyId == (ushort)expectedPropertyName)
                        {
                            isExpectedPropertyInPropertyList = true;
                            for (int j = 0; j < getNormalMailMessageContent.RowData.PropertyRows.Count; j++)
                            {
                                string propertyValue = AdapterHelper.PropertyValueConvertToString(getNormalMailMessageContent.RowData.PropertyRows[j].PropertyValues[i].Value);
                                if (propertyValue.Contains(expectedPropertyValue))
                                {
                                    expectedMessageIndex = j;
                                    return getNormalMailMessageContent;
                                }
                            }
                        }
                    }

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

                if (repeatTime == this.getMessageRepeatTime)
                {
                    break;
                }

                Thread.Sleep(this.WaitForTheRuleToTakeEffect);
            }

            Site.Assert.Fail("Can't find the message which has a property {0} ant its value is {1} in the target mailbox.", expectedPropertyName.ToString(), expectedPropertyValue);
            return getNormalMailMessageContent;
        }