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;
}