/// <summary>
/// Synchronize item with specified subject.
/// </summary>
/// <param name="subject">The subject of the item.</param>
/// <param name="collectionId">The collection id which to sync with.</param>
/// <param name="commands">The sync commands.</param>
/// <param name="bodyPreferences">The bodyPreference in the options element.</param>
/// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
/// <returns>The item with specified subject.</returns>
protected DataStructures.Sync GetSyncResult(string subject, string collectionId, object[] commands, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
{
DataStructures.SyncStore syncStore;
DataStructures.Sync item = null;
SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(collectionId), collectionId, commands, bodyPreferences, bodyPartPreferences);
int counter = 0;
int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
do
{
Thread.Sleep(waitTime);
syncStore = this.ASAIRSAdapter.Sync(request);
if (syncStore != null && syncStore.CollectionStatus == 1)
{
item = TestSuiteHelper.GetSyncAddItem(syncStore, subject);
}
counter++;
}while ((syncStore == null || item == null) && counter < retryCount);
this.Site.Assert.IsNotNull(item, "The email item with subject {0} should be found, retry count: {1}.", subject, counter);
this.SyncKey = syncStore.SyncKey;
return(item);
}