public void MSASEMAIL_S01_TC26_CreateDraftEMail()
{
Site.Assume.AreEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Bcc element is supported when the ActiveSyncProtocolVersion is 16.0.");
#region Add an email item with Sync command.
// Call FolderSync command to synchronize the collection hierarchy.
FolderSyncRequest folderSyncRequest = Common.CreateFolderSyncRequest("0");
FolderSyncResponse folderSyncResponse = this.EMAILAdapter.FolderSync(folderSyncRequest);
string draftCollectionId = Common.GetDefaultFolderServerId(folderSyncResponse, FolderType.Drafts, this.Site);
string subject = Common.GenerateResourceName(Site, "subject");
string to = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);
string bcc = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain);
Request.SyncCollectionAdd syncAddCollection = new Request.SyncCollectionAdd();
string clientId = TestSuiteHelper.GetClientId();
syncAddCollection.ClientId = clientId;
syncAddCollection.ApplicationData = new Request.SyncCollectionAddApplicationData();
List<object> items = new List<object>();
List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>();
itemsElementName.Add(Request.ItemsChoiceType8.Subject3);
items.Add(subject);
itemsElementName.Add(Request.ItemsChoiceType8.To);
items.Add(to);
itemsElementName.Add(Request.ItemsChoiceType8.Bcc);
items.Add(bcc);
syncAddCollection.ApplicationData.Items = items.ToArray();
syncAddCollection.ApplicationData.ItemsElementName = itemsElementName.ToArray();
syncAddCollection.Class = "Email";
SyncStore initSyncResponse = this.InitializeSync(draftCollectionId);
SyncRequest addEMailRequest = TestSuiteHelper.CreateSyncAddRequest(initSyncResponse.SyncKey, draftCollectionId, syncAddCollection);
this.EMAILAdapter.Sync(addEMailRequest);
#endregion
#region Call Sync command wihtout including BodyPreference to synchronize the e-mail items with server.
// Get the new added email item
SyncStore syncChangeResult = this.GetSyncResult(subject, draftCollectionId, null);
Sync item = TestSuiteHelper.GetSyncAddItem(syncChangeResult, subject);
this.Site.CaptureRequirementIfAreEqual<bool>(
true,
item.Email.IsDraft.Value,
1278,
@"[In IsDraft] The value 1 (TRUE) indicates that the email is a draft.");
this.Site.CaptureRequirementIfIsNotNull(
item.Email.IsDraft,
1273,
@"[In IsDraft] This element [email2:IsDraft] is present in a Sync command response ([MS-ASCMD] section 2.2.2.20)[, a Search command response ([MS-ASCMD] section 2.2.2.15), or an ItemOperations command response ([MS-ASCMD] section 2.2.2.9)].");
this.Site.CaptureRequirementIfIsTrue(
!string.IsNullOrEmpty(item.Email.ConversationId),
1184,
@"[In ConversationId] In protocol version 16.0: When the client adds a new draft item, the server response will contain the email2:ConversationId element for that draft item.");
this.Site.CaptureRequirementIfIsTrue(
!string.IsNullOrEmpty(item.Email.ConversationIndex),
1190,
@"[In ConversationIndex] In protocol version 16.0: When the client adds a new draft item, the server response will include the email2:ConversationIndex element for that draft item.");
#endregion
#region Call Search command to Search email from server.
// Search email from server
SearchRequest searchRequest = TestSuiteHelper.CreateSearchRequest(subject, draftCollectionId);
SearchResponse searchResponse = this.EMAILAdapter.Search(searchRequest);
SearchStore searchStore = Common.LoadSearchResponse(searchResponse);
Search searchItem = null;
if (searchStore.Results.Count != 0)
{
foreach (Search resultItem in searchStore.Results)
{
if (resultItem.Email.Subject == subject)
{
searchItem = resultItem;
break;
}
}
}
Site.Assert.IsNotNull(searchItem, "The email message with subject {0} should be found.", subject);
this.Site.CaptureRequirementIfIsNotNull(
searchItem.Email.IsDraft,
1274,
@"[In IsDraft] This element [email2:IsDraft] is present in [a Sync command response ([MS-ASCMD] section 2.2.2.20),] a Search command response ([MS-ASCMD] section 2.2.2.15)[, or an ItemOperations command response ([MS-ASCMD] section 2.2.2.9)].");
#endregion
#region Call ItemOperations command without including BodyPreference element to fetch all the information about the e-mail
ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(draftCollectionId, item.ServerId, null, null, null);
ItemOperationsStore itemOperationResult = this.EMAILAdapter.ItemOperations(itemOperationRequest);
ItemOperations itemOperationsItem = TestSuiteHelper.GetItemOperationsItem(itemOperationResult, subject);
this.Site.CaptureRequirementIfIsNotNull(
itemOperationsItem.Email.IsDraft,
1275,
@"[In IsDraft] This element [email2:IsDraft] is present in [a Sync command response ([MS-ASCMD] section 2.2.2.20), a Search command response ([MS-ASCMD] section 2.2.2.15), or] an ItemOperations command response ([MS-ASCMD] section 2.2.2.9).");
#endregion
}
#endregion