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

GetExpectedMessage() protected method

Get the expected message properties included in a specific contents table after retry preconfigured times.
protected GetExpectedMessage ( uint folderHandle, uint &contentsTableHandle, PropertyTag propertyTagList, int &expectedMessageIndex, string expectedPropertyValue, PropertyId expectedPropertyName = PropertyId.PidTagSubject ) : RopQueryRowsResponse
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.
expectedMessageIndex int The index of the specific message in the table.
expectedPropertyValue string The value of a specific property of the message to be found in the target mailbox.
expectedPropertyName Microsoft.Protocols.TestSuites.Common.PropertyId 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.
return Microsoft.Protocols.TestSuites.Common.RopQueryRowsResponse
        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;
        }

Same methods

TestSuiteBase::GetExpectedMessage ( uint folderHandle, uint &contentsTableHandle, PropertyTag propertyTagList, uint &rowCount, int expectedMessageCount = 1, string expectedTitle = null ) : RopQueryRowsResponse