private void DeleteItemsInFolder(Collection<CreatedItems> createdItemsCollection)
{
foreach (CreatedItems createdItems in createdItemsCollection)
{
string syncKey = this.GetInitialSyncKey(createdItems.CollectionId);
SyncRequest request = TestSuiteHelper.CreateSyncRequest(syncKey, createdItems.CollectionId, null, null, null);
DataStructures.SyncStore result = this.ASAIRSAdapter.Sync(request);
List<Request.SyncCollectionDelete> deleteData = new List<Request.SyncCollectionDelete>();
foreach (string subject in createdItems.ItemSubject)
{
string serverId = null;
if (result != null)
{
foreach (DataStructures.Sync item in result.AddElements)
{
if (item.Email.Subject != null && item.Email.Subject.Equals(subject, StringComparison.CurrentCulture))
{
serverId = item.ServerId;
break;
}
if (item.Contact.FileAs != null && item.Contact.FileAs.Equals(subject, StringComparison.CurrentCulture))
{
serverId = item.ServerId;
break;
}
if (item.Calendar.Subject != null && item.Calendar.Subject.Equals(subject, StringComparison.CurrentCulture))
{
serverId = item.ServerId;
break;
}
}
}
this.Site.Assert.IsNotNull(serverId, "The item with subject '{0}' should be found!", subject);
deleteData.Add(new Request.SyncCollectionDelete() { ServerId = serverId });
}
Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(result.SyncKey, createdItems.CollectionId);
syncCollection.Commands = deleteData.ToArray();
syncCollection.DeletesAsMoves = false;
syncCollection.DeletesAsMovesSpecified = true;
SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
DataStructures.SyncStore deleteResult = this.ASAIRSAdapter.Sync(syncRequest);
this.Site.Assert.AreEqual<byte>(
1,
deleteResult.CollectionStatus,
"The value of Status should be 1 to indicate the Sync command executes successfully.");
}
}
#endregion