/// <summary> /// Verify the validation of a response of CreateItem operation returned by server. /// </summary> /// <param name="createItemResponse">A response of CreateItem operation returned by server.</param> /// <param name="messageDisposition">A value specifies how a message item is handled after it is created or updated.</param> /// <returns>The validation result.</returns> protected bool VerifyCreateItemResponse(CreateItemResponseType createItemResponse, MessageDispositionType messageDisposition) { bool isValidCreateResponse = false; if (this.VerifyResponse(createItemResponse)) { this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); Site.Assert.IsNotNull(this.infoItems, @"The CreateItem response should contain one or more items of ItemInfoResponseMessageType."); switch (messageDisposition) { case MessageDispositionType.SaveOnly: this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); isValidCreateResponse = true; break; case MessageDispositionType.SendAndSaveCopy: case MessageDispositionType.SendOnly: Site.Assert.IsTrue(this.infoItems.Length > 0, "infoItems instance should contain at least one item."); Site.Assert.IsNotNull(this.infoItems[0], "The first item of infoItems instance should not be null."); Site.Assert.IsNotNull(this.infoItems[0].Items, "The Items property of the first item of infoItems instance should not be null."); break; } isValidCreateResponse = true; } return(isValidCreateResponse); }
public void MSOXWSMSG_S04_TC01_MoveMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the moveItem response. ItemIdType moveItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); moveItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; moveItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Verify whether the message is moved to junkemail folder. string userName = Common.GetConfigurationPropertyValue("Sender", this.Site); string password = Common.GetConfigurationPropertyValue("SenderPassword", this.Site); string domain = Common.GetConfigurationPropertyValue("Domain", this.Site); bool findItemInDrafts = this.IsItemAvailableAfterMoveOrDelete(userName, password, domain, "drafts", this.Subject, "itemSubject"); Site.Assert.IsFalse(findItemInDrafts, "The item should not be found in the drafts folder of Sender."); bool findItemInJunkemail = this.SearchItems(Role.Sender, "junkemail", this.Subject, "itemSubject"); Site.Assert.IsTrue(findItemInJunkemail, "The item should be found in the junkemail folder of Sender."); #region Verify the requirements about MoveItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R161"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R161 Site.CaptureRequirementIfIsNotNull( moveItemResponse, 161, @"[In MoveItem] The protocol client sends a MoveItemSoapIn request WSDL message, and the protocol server responds with a MoveItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R162"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R162 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 162, @"[In MoveItem] If the MoveItem WSDL operation request is successful, the server returns a MoveItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.7.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R163 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 163, @"[In MoveItem] [A successful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the moved message DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { moveItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }
public void MSOXWSMSG_S04_TC02_MoveMessageUnsuccessful() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Delete the message created DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163001"); this.Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Error, moveItemResponse.ResponseMessages.Items[0].ResponseClass, 163001, @"[In MoveItem] If the MoveItem WSDL operation request is not successful, it returns a MoveItemResponse element with the ResponseClass attribute of the MoveItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163002"); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), moveItemResponse.ResponseMessages.Items[0].ResponseCode), 163002, @"[In MoveItem] [A unsuccessful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element of the MoveItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #endregion }
public void MSOXWSMSG_S02_TC01_UpdateMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem returned from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region update ToRecipients property of the original message UpdateItemType updateItemRequest = new UpdateItemType { MessageDisposition = MessageDispositionType.SaveOnly, MessageDispositionSpecified = true, ItemChanges = new ItemChangeType[] { new ItemChangeType { Item = itemIdType, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update the ToRecipients of message from Recipient1 to Recipient2. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } } } } } } } }; UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest); Site.Assert.IsTrue(this.VerifyResponse(updateItemResponse), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the UpdateItem response. if (this.firstItemOfFirstInfoItem != null) { Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; } #region Verify the requirements about UpdateItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R143"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R143 Site.CaptureRequirementIfIsNotNull( updateItemResponse, 143, @"[In UpdateItem] The protocol client sends an UpdateItemSoapIn request WSDL message, and the protocol server responds with an UpdateItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R144"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R144 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 144, @"[In UpdateItem] If the UpdateItem WSDL operation request is successful, the server returns an UpdateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.9.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R145"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R145 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 145, @"[In UpdateItem] [A successful UpdateItem operation request returns an UpdateItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the UpdateItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Get the updated message GetItemType getItemRequest = DefineGeneralGetItemRequestMessage(itemIdType, DefaultShapeNamesType.AllProperties); GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(getItemResponse); Site.Assert.IsNotNull(this.infoItems, @"The GetItem response should contain one or more items of ItemInfoResponseMessageType."); ItemType updatedItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(updatedItem, @"The updated message should exist"); string expectedValue = Common.GetConfigurationPropertyValue("Recipient2", this.Site); Site.Assert.AreEqual <string>( expectedValue.ToLower(), updatedItem.DisplayTo.ToLower(), string.Format("The expected value of the DisplayTo property is {0}. The actual value is {1}.", expectedValue, updatedItem.DisplayTo)); #endregion #region Clean up Sender's drafts folder bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Sender", this.Site), Common.GetConfigurationPropertyValue("SenderPassword", this.Site), this.Domain, this.Subject, "drafts"); Site.Assert.IsTrue(isClear, "Sender's drafts folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S05_TC01_SendMessage() { #region Create the message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType = new ItemIdType(); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message SendItemType sendItemRequest = new SendItemType { ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, // Save the message copy in sent items folder. SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyResponse(sendItemResponse), @"Server should return success for sending the email messages."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items, @"Items in the returned response should not be null."); #region Verify the requirements about SendItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R177"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R177 Site.CaptureRequirementIfIsNotNull( sendItemResponse, 177, @"[In SendItem] The protocol client sends a SendItemSoapIn request WSDL message, and the protocol server responds with a SendItemSoapOut response WSDL message."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R178"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R178 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponse.ResponseMessages.Items[0].ResponseClass, 178, @"[In SendItem] A successful SendItem operation request returns a SendItemResponse element with the ResponseClass attribute of the SendItemResponseMessage element set to ""Success""."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R179"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R179 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, sendItemResponse.ResponseMessages.Items[0].ResponseCode, 179, @"[In SendItem] [A successful SendItem operation request returns a SendItemResponse element] The ResponseCode element of the SendItemResponse element is set to ""NoError""."); #endregion #endregion #region Create the invalid message for SendItem operation without ToRecipients element CreateItemType createItemRequestFailed = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, Subject = this.Subject, } } }, }; CreateItemResponseType createItemResponseFailed = this.MSGAdapter.CreateItem(createItemRequestFailed); Site.Assert.IsTrue(this.VerifyResponse(createItemResponseFailed), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponseFailed); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message without ToRecipients element SendItemType sendItemRequestFailed = new SendItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponseFailed = this.MSGAdapter.SendItem(sendItemRequestFailed); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R31"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R31 Site.CaptureRequirementIfAreNotEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponseFailed.ResponseMessages.Items[0].ResponseClass, 31, @"[In t:MessageType Complex Type] [ToRecipients element] This element is required for sending a message."); #endregion #region Delete the invalid message DeleteItemType deleteItemRequest = new DeleteItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Sender's sentitems folder and Recipient1's inbox folder bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Sender", this.Site), Common.GetConfigurationPropertyValue("SenderPassword", this.Site), this.Domain, this.Subject, "sentitems"); Site.Assert.IsTrue(isClear, "Sender's sentitems folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, this.Subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S06_TC01_OperateMultipleMessages() { #region Create multiple message string subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 0); string anotherSubject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 1); CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { // Create an responseMessageItem with two MessageType instances. Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, Subject = subject, }, new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } }, Subject = anotherSubject, } } }, }; CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(createItemResponse), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the first ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType1 = new ItemIdType(); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the second ItemId. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType itemIdType2 = new ItemIdType(); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Get the multiple messages which created GetItemType getItemRequest = new GetItemType { // Set the two ItemIds got from CreateItem response. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(getItemResponse), @"Server should return success for creating the email messages."); #endregion #region Update the multiple messages which created UpdateItemType updateItemRequest = new UpdateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, // Create two ItemChangeType instances. ItemChanges = new ItemChangeType[] { new ItemChangeType { Item = itemIdType1, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the first message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } } } }, } }, new ItemChangeType { Item = itemIdType2, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the second message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } } } }, } } } }; UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(updateItemResponse), @"Server should return success for updating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(updateItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the UpdateItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the UpdateItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Copy the updated multiple message to junkemail CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType1, itemIdType2, }, // Copy the message to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the CopyItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType copyItemIdType1 = new ItemIdType(); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the CopyItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType copyItemIdType2 = new ItemIdType(); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Move the copied multiple message from junkemail to deleteditems MoveItemType moveItemRequest = new MoveItemType { // Set to copied message responseMessageItem id. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 }, // Move the copied messages to deleted items folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.deleteditems } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the MoveItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the MoveItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Send multiple messages SendItemType sendItemRequest = new SendItemType { // Set to the two updated messages' ItemIds. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, // Do not save copy. SaveItemToFolder = false, }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(sendItemResponse), @"Server should return success for sending the email messages."); #endregion #region Delete the copied messages DeleteItemType deleteItemRequest = new DeleteItemType { // Set to the two copied messages' ItemIds. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Recipient1's and Recipient2's inbox folders bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient2", this.Site), Common.GetConfigurationPropertyValue("Recipient2Password", this.Site), this.Domain, subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient2's inbox folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, anotherSubject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S03_TC01_CopyMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Copy message CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType }, // Save the copy message to inbox folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type from server response should not be null."); // Save the ItemId of message responseMessageItem got from the copyItem response. ItemIdType copyItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #region Verify the requirements about CopyItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R168"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R168 Site.CaptureRequirementIfIsNotNull( copyItemResponse, 168, @"[In CopyItem] The protocol client sends a CopyItemSoapIn request WSDL message, and the protocol server responds with a CopyItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R169"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R169 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, copyItemResponse.ResponseMessages.Items[0].ResponseClass, 169, @"[In CopyItem] If the CreateItem WSDL operation request is successful, the server returns a CreateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.2.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R170"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R170 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, copyItemResponse.ResponseMessages.Items[0].ResponseCode, 170, @"[In CopyItem] [A successful CopyItem operation request returns a CopyItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the copied Email messages DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { itemIdType, copyItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }