public void MSASAIRS_S03_TC01_FileReference_ZeroLengthString() { #region Send a mail with normal attachment. string subject = Common.GenerateResourceName(Site, "Subject"); string body = Common.GenerateResourceName(Site, "Body"); this.SendEmail(EmailType.NormalAttachment, subject, body); #endregion #region Send an ItemOperations request with the value of FileReference element as a zero-length string. DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null); // Send an ItemOperations request with the value of FileReference element as a zero-length string. ItemOperationsRequest request = TestSuiteHelper.CreateItemOperationsRequest(this.User2Information.InboxCollectionId, syncItem.ServerId, string.Empty, null, null); DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, DeliveryMethodForFetch.Inline); Site.Assert.AreEqual <int>( 1, itemOperationsStore.Items.Count, "There should be 1 item in ItemOperations response."); #endregion #region Verify requirements // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R214"); // Verify MS-ASAIRS requirement: MS-ASAIRS_R214 Site.CaptureRequirementIfAreEqual <string>( "15", itemOperationsStore.Items[0].Status, 214, @"[In FileReference (Fetch)] If the client includes a zero-length string for the value of this element [the FileReference (Fetch) element] in an ItemOperations command request, the server responds with a protocol status error of 15."); #endregion }
/// <summary> /// Fetch item with specified ServerID on the server. /// </summary> /// <param name="collectionId">The collection id.</param> /// <param name="serverId">The server id of the mail.</param> /// <param name="fileReference">The file reference of the attachment.</param> /// <param name="bodyPreferences">The bodyPreference in the options element.</param> /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param> /// <param name="deliveryMethod">Indicate whether use multipart or inline method to send the request.</param> /// <returns>The item with specified ServerID.</returns> protected DataStructures.ItemOperations GetItemOperationsResult(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences, DeliveryMethodForFetch?deliveryMethod) { DataStructures.ItemOperations item = null; ItemOperationsRequest request = TestSuiteHelper.CreateItemOperationsRequest(collectionId, serverId, fileReference, 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); DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, deliveryMethod ?? DeliveryMethodForFetch.Inline); // Since the item serverId or attachment fileReference is unique, there should be only one item in response this.Site.Assert.AreEqual <int>( 1, itemOperationsStore.Items.Count, "The count of Items in ItemOperations command response should be 1."); if (itemOperationsStore.Items[0].Email != null) { item = itemOperationsStore.Items[0]; } }while (item == null && counter < retryCount); this.Site.Assert.IsNotNull(item, "The item should be found, retry count: {0}.", counter); return(item); }
/// <summary> /// Verify the rights-managed requirements about ItemOperations response. /// </summary> /// <param name="itemOperationsStore">The wrapper class for the fetched result of ItemOperations command.</param> private void VerifyItemOperationsResponse(ItemOperationsStore itemOperationsStore) { foreach (ItemOperations itemOperations in itemOperationsStore.Items) { if (itemOperations.Email != null) { if (itemOperations.Email.RightsManagementLicense != null) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R210"); // Verify MS-ASRM requirement: MS-ASRM_R210 Site.CaptureRequirementIfIsTrue( this.activeSyncClient.ValidationResult, 210, @"[In Sending Rights-Managed E-Mail Messages to the Client] In an ItemOperations command response, the RightsManagementLicense element is included as a child of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128.1)."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R410"); // Verify MS-ASRM requirement: MS-ASRM_R410 Site.CaptureRequirementIfIsTrue( this.activeSyncClient.ValidationResult, 410, @"[In Sending Rights-Managed E-Mail Messages to the Client] To respond to an ItemOperations command request message that includes the RightsManagementSupport element, the server includes the RightsManagementLicense element and its child elements in the ItemOperations command response message."); this.VerifyRightsManagementLicense(itemOperations.Email.RightsManagementLicense); } } } }
/// <summary> /// This method is used to verify the ItemOperations response related requirement. /// </summary> /// <param name="itemOperationsResponse">Specified ItemOperationsStore result returned from the server.</param> private void VerifyItemOperationsResponse(ItemOperationsStore itemOperationsResponse) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R353"); // Verify MS-ASTASK requirement: MS-ASTASK_R353 Site.CaptureRequirementIfAreEqual<string>( "1", itemOperationsResponse.Status, 353, @"[In Requesting Details for Specific Tasks][If the client sends an ItemOperations command request to the server] The server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8)."); }
/// <summary> /// This method is used to verify the ItemOperations command response related requirements. /// </summary> /// <param name="itemOperationsStore">The ItemOperations result returned from the server.</param> private void VerifyItemOperationsResponse(ItemOperationsStore itemOperationsStore) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R477"); // Verify MS-ASCNTC requirement: MS-ASCNTC_R477 Site.CaptureRequirementIfIsTrue( this.activeSyncClient.ValidationResult, 477, @"[In Retrieving Details for Specific Contacts] [If a client sends an ItemOperations command request to the server]The server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8)."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R483"); // Verify MS-ASCNTC requirement: MS-ASCNTC_R483 Site.CaptureRequirementIfIsTrue( this.activeSyncClient.ValidationResult, 483, @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.8) to retrieve data from the server for one or more contact items, as specified in section 3.1.5.1, the server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8)."); // If the validation is successful, then MS-ASCNTC_R486 can be captured. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R486"); // Verify MS-ASCNTC requirement: MS-ASCNTC_R486 Site.CaptureRequirementIfIsTrue( this.activeSyncClient.ValidationResult, 486, @"[In ItemOperations Command Response] Contact class elements are returned as child elements of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128) in the ItemOperations command response."); foreach (ItemOperations itemOperations in itemOperationsStore.Items) { if (itemOperations.Contact != null) { this.VerifyContactClassElements(itemOperations.Contact); } } this.VerifyMessageSyntax(); this.VerifyAbstractDataModel(); }
/// <summary> /// Convert the ItemOperationsResponse to ItemOperationsStore /// </summary> /// <param name="itemOperations">The returned ItemOperations response.</param> /// <returns>An ItemOperationsStore instance</returns> public static DataStructures.ItemOperationsStore LoadItemOperationsResponse(ItemOperationsResponse itemOperations) { DataStructures.ItemOperationsStore store = new DataStructures.ItemOperationsStore { Status = itemOperations.ResponseData.Status }; if (itemOperations.ResponseData.Response != null && itemOperations.ResponseData.Response.Fetch != null) { foreach (Response.ItemOperationsResponseFetch item in itemOperations.ResponseData.Response.Fetch) { DataStructures.ItemOperations fetchItem = new DataStructures.ItemOperations { Status = item.Status, Class = item.Class, ServerId = item.ServerId, CollectionId = item.CollectionId }; if (item.Properties != null) { fetchItem.Calendar = DataStructures.Calendar.DeserializeFromFetchProperties<DataStructures.Calendar>(item.Properties); fetchItem.Email = DataStructures.Email.DeserializeFromFetchProperties<DataStructures.Email>(item.Properties); fetchItem.Note = DataStructures.Note.DeserializeFromFetchProperties<DataStructures.Note>(item.Properties); fetchItem.Contact = DataStructures.Contact.DeserializeFromFetchProperties<DataStructures.Contact>(item.Properties); fetchItem.Task = DataStructures.Task.DeserializeFromFetchProperties<DataStructures.Task>(item.Properties); } store.Items.Add(fetchItem); } } return store; }
/// <summary> /// Get the email item from the ItemOperations response by using the subject as the search criteria. /// </summary> /// <param name="itemOperationsResult">The ItemOperations command result.</param> /// <param name="subject">The email subject.</param> /// <returns>Return the right email item from the sync response.</returns> internal static ItemOperations GetItemOperationsItem(ItemOperationsStore itemOperationsResult, string subject) { ItemOperations item = null; if (itemOperationsResult.Items != null) { foreach (ItemOperations itemOperationsItem in itemOperationsResult.Items) { if (itemOperationsItem.Email.Subject == subject) { item = itemOperationsItem; break; } } } return item; }