/// <summary> /// Clean up the environment. /// </summary> protected override void TestCleanup() { ExchangeServiceBinding.ServiceResponseEvent -= new ExchangeServiceBinding.ServiceResponseDelegate(this.ExchangeServiceBinding_ResponseEvent); if (this.ExistContactItems != null && this.ExistContactItems.Count > 0) { // Get ItemIds. DeleteItemType deleteItemRequest = new DeleteItemType(); ItemIdType[] itemArray = new ItemIdType[this.ExistContactItems.Count]; this.ExistContactItems.CopyTo(itemArray, 0); deleteItemRequest.ItemIds = itemArray; // Configure an enumeration value that describes the item is to be deleted permanently. deleteItemRequest.DeleteType = DisposalType.HardDelete; DeleteItemResponseType deleteItemResponse = this.CONTAdapter.DeleteItem(deleteItemRequest); foreach (ResponseMessageType messageType in deleteItemResponse.ResponseMessages.Items) { Site.Assert.AreEqual<ResponseCodeType>( ResponseCodeType.NoError, messageType.ResponseCode, string.Format( "Delete contact item should not fail! Expected response code: {0}, actual response code: {1}", ResponseCodeType.NoError, messageType.ResponseCode)); } } // Clear ExistItemIds for DeleteItem. this.InitializeCollection(); base.TestCleanup(); }
public void MSOXWSFOLD_S05_TC05_SoftEmptyFolder() { Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation"); Site.Assume.IsTrue(Common.IsRequirementEnabled(4000, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not include enumeration value recoverableitemsdeletions"); #region Create a new folder in the inbox folder // CreateFolder request. CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null); // Create a new folder. CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest); // Check the response. Common.CheckOperationSuccess(createFolderResponse, 1, this.Site); // Save the new created folder's folder id. FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId; this.NewCreatedFolderIds.Add(newFolderId); #endregion #region Create an item string itemName = Common.GenerateResourceName(this.Site, "Test Mail"); // Create an item in the new created folder. ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName); Site.Assert.IsNotNull(itemId, "Item should be created successfully!"); #endregion #region Get the new created folder // GetFolder request. GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId); // Get the new created folder. GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest); // Check the response. Common.CheckOperationSuccess(getFolderResponse, 1, this.Site); #endregion #region Empty the created folder EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(newFolderId, DisposalType.SoftDelete, true); Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site); #endregion #region Find the item ItemIdType findItemID = this.FindItem(DistinguishedFolderIdNameType.recoverableitemsdeletions.ToString(), itemName); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSFOLD_R37803"); this.Site.CaptureRequirementIfIsNotNull( findItemID, 37803, @"[In m:EmptyFolderType Complex Type ]DeleteType which value is SoftDelete specifies that an item or folder is moved to the dumpster if the dumpster is enabled."); DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { findItemID }; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); #endregion }
/// <remarks/> public void DeleteItemAsync(DeleteItemType DeleteItem1) { this.DeleteItemAsync(DeleteItem1, null); }
/// <summary> /// Delete contact item on the server. /// </summary> /// <param name="deleteItemRequest">The request of DeleteItem operation.</param> /// <returns>A response to DeleteItem operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); #region Verify DeleteItem operation requirements this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyDeleteContactItem(this.exchangeServiceBinding.IsSchemaValidated); #endregion return deleteItemResponse; }
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_S01_TC05_GetAndDeleteMessageUnsuccessful() { #region Create a message with all elements except ReceivedBy and ReceivedRepresenting elements 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); #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 Get the created message via itemIdType in above steps GetItemType getItemRequest = DefineGeneralGetItemRequestMessage(this.firstItemOfFirstInfoItem.ItemId, DefaultShapeNamesType.IdOnly); GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R135001"); this.Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Error, getItemResponse.ResponseMessages.Items[0].ResponseClass, 135001, @"[In GetItem] If the GetItem WSDL operation request is not successful, it returns a GetItemResponse element with the ResponseClass attribute of the GetItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R135002"); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), getItemResponse.ResponseMessages.Items[0].ResponseCode), 135002, @"[In GetItem] [A unsuccessful GetItem operation request returns a GetItemResponse element] The ResponseCode element of the GetItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #endregion #region Delete the message deleted. ItemIdType itemId = new ItemIdType() { Id = this.firstItemOfFirstInfoItem.ItemId.Id + "invalid", ChangeKey = this.firstItemOfFirstInfoItem.ItemId.Id, }; deleteItemRequest.ItemIds = new ItemIdType[] { itemId }; deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); this.Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Error, deleteItemResponse.ResponseMessages.Items[0].ResponseClass, 154001, @"[In DeleteItem] If the DeleteItem WSDL operation request is not successful, it returns a DeleteItemResponse element with the ResponseClass attribute of the DeleteItemResponseMessage element set to ""Error"". "); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), deleteItemResponse.ResponseMessages.Items[0].ResponseCode), 154002, @"[In DeleteItem] [A unsuccessful DeleteItem operation request returns a DeleteItemResponse element] The ResponseCode element of the DeleteItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #endregion }
public void MSOXWSMSG_S01_TC08_GetMessageWithBodyTypeAndAdditionProperties() { #region Create a message. #region Define a CreateItem request CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, // Define the message which contains all the elements except ReceivedBy and ReceivedRepresenting. Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { // Create a MessageType instance with all element. new MessageType { // Specify the recipient of the message. ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, // Specify the subject of message. Subject = this.Subject, Body = new BodyType() { BodyType1 = BodyTypeType.HTML, Value = "<html><body><b>Bold</b>test</body></html>" } } } }, }; #endregion 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); #endregion #region Get the created message via itemIdType in above steps #region Send the GetItem requst which the BodyType element is set to text. GetItemType getItemRequest = new GetItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, BodyType = BodyTypeResponseType.Text, BodyTypeSpecified = true, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), "The response of the GetItem should be valid."); MessageType message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1190"); this.Site.CaptureRequirementIfAreEqual<BodyTypeType>( BodyTypeType.Text, message.Body.BodyType1, "MS-OXWSCDATA", 1190, @"[In t:ItemResponseShapeType Complex Type] The element ""BodyType"" with type ""t:BodyTypeResponseType(section 2.2.3.1)"" specifies the requested body text format for the Body property that is returned in a response."); #endregion #region Send the GetItem requst which the BaseShape element is set to IdOnly and addition the subject property. getItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.IdOnly; getItemRequest.ItemShape.AdditionalProperties = new BasePathToElementType[] { new PathToUnindexedFieldType() { FieldURI = UnindexedFieldURIType.itemSubject, } }; getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages."); message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1197"); this.Site.CaptureRequirementIfIsTrue( string.IsNullOrEmpty(message.Subject) == false, "MS-OXWSCDATA", 1197, @"[In t:ItemResponseShapeType Complex Type] The element ""AdditionalProperties"" with type ""t:NonEmptyArrayOfPathsToElementType"" specifies a set of requested additional properties to return in a response."); #endregion #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 }
/// <summary> /// Clean up the items which contain a specified subject in the specified folder. /// </summary> /// <param name="folder">The folder to be cleaned up.</param> /// <param name="subject">Subject of the item to be removed.</param> /// <returns>If succeed, return true; otherwise, return false.</returns> private bool CleanupFolder(string folder, string subject) { ItemIdType[] items = this.GetItemIds(folder, subject); if (items != null && items.Length > 0) { DeleteItemType deleteItem = new DeleteItemType(); deleteItem.ItemIds = items; deleteItem.DeleteType = DisposalType.HardDelete; deleteItem.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItem.SendMeetingCancellationsSpecified = true; DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItem); if (response.ResponseMessages.Items != null) { foreach (ResponseMessageType item in response.ResponseMessages.Items) { if (item.ResponseClass != ResponseClassType.Success) { return false; } } } } return true; }
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 MSOXWSCORE_S05_TC18_DeleteMeetingItemWithThreeItemIdTypesSuccessfully() { #region Step 1: Create and get a recurring calendar item. DateTime start = DateTime.Now; int numberOfOccurrences = 5; CalendarItemType calendar = this.CreateAndGetRecurringCalendarItem(start, numberOfOccurrences); #endregion #region Step 2: Delete the recurring calendar item by ItemIdType. DeleteItemResponseType deleteItemResponse = this.CallDeleteItemOperation(); // Check the operation response. Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); // Clear ExistItemIds for DeleteItem. this.InitializeCollection(); #endregion #region Step 3: Create and get a recurring calendar item. calendar = this.CreateAndGetRecurringCalendarItem(start, numberOfOccurrences); #endregion #region Step 4: Delete the recurrence master calendar item by RecurringMasterItemIdType. DeleteItemType deleteItemRequest = new DeleteItemType(); // The calendar item to delete. RecurringMasterItemIdType[] recurringMasterItemIds = new RecurringMasterItemIdType[1]; recurringMasterItemIds[0] = new RecurringMasterItemIdType(); recurringMasterItemIds[0].OccurrenceId = calendar.FirstOccurrence.ItemId.Id; recurringMasterItemIds[0].ChangeKey = calendar.FirstOccurrence.ItemId.ChangeKey; deleteItemRequest.ItemIds = recurringMasterItemIds; // Enumeration value to describe how an item is to be deleted. deleteItemRequest.DeleteType = DisposalType.HardDelete; // AffectedTaskOccurrences indicates whether a task instance or a task master is to be deleted. deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.AllOccurrences; // SendMeetingCancellations describes how cancellations are to be handled for deleted meetings. deleteItemRequest.SendMeetingCancellationsSpecified = true; deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); // Check the operation response. Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); // Clear ExistItemIds for DeleteItem. this.InitializeCollection(); #endregion #region Step 5: Create and get a recurring calendar item. calendar = this.CreateAndGetRecurringCalendarItem(start, numberOfOccurrences); #endregion #region Step 6: Delete the first occurrence of the recurring calendar item by OccurrenceItemIdType. deleteItemRequest = new DeleteItemType(); // The calendar item to delete. OccurrenceItemIdType[] occurrenceItemIds = new OccurrenceItemIdType[1]; occurrenceItemIds[0] = new OccurrenceItemIdType(); occurrenceItemIds[0].RecurringMasterId = calendar.ItemId.Id; occurrenceItemIds[0].ChangeKey = calendar.FirstOccurrence.ItemId.ChangeKey; occurrenceItemIds[0].InstanceIndex = 1; deleteItemRequest.ItemIds = occurrenceItemIds; // Enumeration value to describe how an item is to be deleted. deleteItemRequest.DeleteType = DisposalType.HardDelete; // AffectedTaskOccurrences indicates whether a task instance or a task master is to be deleted. deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.AllOccurrences; // SendMeetingCancellations describes how cancellations are to be handled for deleted meetings. deleteItemRequest.SendMeetingCancellationsSpecified = true; deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); // Check the operation response. Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); #endregion }
/// <summary> /// Deletes Task items on the server. /// </summary> /// <param name="deleteItemRequest">Specifies a request to delete Task item on the server.</param> /// <returns>A response to this operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); // Verify the delete item operation. this.VerifyDeleteItemOperation(this.exchangeServiceBinding.IsSchemaValidated); // Verify Soap version requirements. this.VerifySoapVersion(); // Verify transport requirements. this.VerifyTransportType(); return deleteItemResponse; }
public void MSOXWSMTGS_S01_TC21_DeleteItemErrorSendMeetingCancellationsRequired() { #region Define a recurring calendar item DateTime startTime = DateTime.Now; DailyRecurrencePatternType pattern = new DailyRecurrencePatternType(); pattern.Interval = this.PatternInterval; NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType(); range.NumberOfOccurrences = this.NumberOfOccurrences; range.StartDate = startTime; CalendarItemType calendarItem = new CalendarItemType(); calendarItem.UID = Guid.NewGuid().ToString(); calendarItem.Subject = this.Subject; calendarItem.Start = startTime; calendarItem.StartSpecified = true; calendarItem.End = startTime.AddHours(this.TimeInterval); calendarItem.EndSpecified = true; calendarItem.Recurrence = new RecurrenceType(); calendarItem.Recurrence.Item = pattern; calendarItem.Recurrence.Item1 = range; #endregion #region Create the recurring calendar item and extract the Id of an occurrence item ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone); OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType(); occurrenceItemId.ChangeKey = item.Items.Items[0].ItemId.ChangeKey; occurrenceItemId.RecurringMasterId = item.Items.Items[0].ItemId.Id; occurrenceItemId.InstanceIndex = this.InstanceIndex; #endregion #region Get the targeted occurrence item ItemInfoResponseMessageType getItem = this.GetSingleCalendarItem(Role.Organizer, occurrenceItemId); Site.Assert.IsNotNull(getItem, @"Get the occurrence should be successful."); RecurringMasterItemIdType invalidRecurringMasterItemId = new RecurringMasterItemIdType(); invalidRecurringMasterItemId.ChangeKey = getItem.Items.Items[0].ItemId.ChangeKey; invalidRecurringMasterItemId.OccurrenceId = getItem.Items.Items[0].ItemId.Id; #endregion #region Delete the occurrence DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { occurrenceItemId }; deleteItemRequest.DeleteType = DisposalType.HardDelete; DeleteItemResponseType deleteItemResponse = this.MTGSAdapter.DeleteItem(deleteItemRequest); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1209"); // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1209 Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Error, deleteItemResponse.ResponseMessages.Items[0].ResponseClass, 1209, @"[In Messages] If the request is unsuccessful, the DeleteItem operation returns a DeleteItemResponse element with the ResponseClass attribute of the DeleteItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1213"); // Verify MS-OXWSMSG requirement: MS-OXWSMTGS_R1213 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.ErrorSendMeetingCancellationsRequired, deleteItemResponse.ResponseMessages.Items[0].ResponseCode, 1213, @"[In Messages] ErrorSendMeetingCancellationsRequired: Occurs during a DeleteItem call, when the SendMeetingCancellations property is missing from the request and the item to delete is a calendar item. "); #endregion #region Clean up organizer's calendar folders. this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.calendar }); #endregion }
public void MSOXWSMTGS_S01_TC17_UpdateAndDeleteoccurrenceOfRecurringMeeting() { #region Organizer creates a recurring meeting // Verify DailyRecurrencePatternType and NumberedRecurrenceRangeType. DailyRecurrencePatternType dailyPattern = new DailyRecurrencePatternType(); NumberedRecurrenceRangeType numberedRange = new NumberedRecurrenceRangeType(); numberedRange.NumberOfOccurrences = this.NumberOfOccurrences; // Define a recurring meeting. CalendarItemType meetingItem = this.DefineRecurringMeeting(dailyPattern, numberedRange); Site.Assert.IsNotNull(meetingItem, "The meeting item should be created."); // Create the recurring meeting. ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, meetingItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll); Site.Assert.IsNotNull(item, "The recurring meeting should be created successfully."); #endregion #region Attendee gets the meeting request MeetingRequestMessageType request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType; Site.Assert.IsNotNull(request, "The meeting request message should be found in attendee's Inbox folder after organizer calls CreateItem with CalendarItemCreateOrDeleteOperationType set to SendOnlyToAll."); #endregion #region Attendee accepts the meeting request AcceptItemType acceptItem = new AcceptItemType(); acceptItem.ReferenceItemId = new ItemIdType(); acceptItem.ReferenceItemId.Id = request.ItemId.Id; item = this.CreateSingleCalendarItem(Role.Attendee, acceptItem, CalendarItemCreateOrDeleteOperationType.SendOnlyToAll); Site.Assert.IsNotNull(item, "Accept the meeting request should be successful."); #endregion #region Attendee gets the accepted meeting request. request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.deleteditems, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType; Site.Assert.IsNotNull(request, "The meeting request should exist in attendee's Deleted Items folder after attendee accepts the meeting request."); Site.Assert.IsTrue(request.IsOutOfDateSpecified, "Element IsOutOfDate should be present."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R751"); // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R751 this.Site.CaptureRequirementIfIsFalse( request.IsOutOfDate, 751, @"[In t:MeetingMessageType Complex Type] otherwise [ there has not been an update to the meeting and the current item in the calendar is not out of date] false."); #endregion #region Organizer gets the calendar item CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType; Site.Assert.IsNotNull(item, "The calendar item should be found in organizer's Calendar folder."); #endregion #region Organizer deletes one of the occurrences of the recurring meeting OccurrenceItemIdType occurrenceId = new OccurrenceItemIdType(); occurrenceId.RecurringMasterId = calendar.ItemId.Id; occurrenceId.InstanceIndex = 1; DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { occurrenceId }; deleteItemRequest.DeleteType = DisposalType.HardDelete; deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendOnlyToAll; deleteItemRequest.SendMeetingCancellationsSpecified = true; DeleteItemResponseType deleteItemResponse = this.MTGSAdapter.DeleteItem(deleteItemRequest); Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType; Site.Assert.IsNotNull(calendar, "The calendar item should exist."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R1214"); // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R1214 // SendMeetingCancellationsSpecified is specified as true, and the occurrence is deleted successfully, this requirement can be captured. this.Site.CaptureRequirement( 1214, @"[In Messages] If you are using the proxy objects, make sure that the SendMeetingCancellationsSpecified property is set to true."); #endregion #region Organizer updates one of the occurrences of the recurring meeting occurrenceId = new OccurrenceItemIdType(); occurrenceId.RecurringMasterId = calendar.ItemId.Id; occurrenceId.ChangeKey = calendar.ItemId.ChangeKey; occurrenceId.InstanceIndex = 2; UpdateItemType updateItemRequest = new UpdateItemType(); updateItemRequest.ItemChanges = new ItemChangeType[1]; updateItemRequest.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy; updateItemRequest.SendMeetingInvitationsOrCancellationsSpecified = true; updateItemRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy; updateItemRequest.MessageDispositionSpecified = true; updateItemRequest.ConflictResolution = ConflictResolutionType.AlwaysOverwrite; updateItemRequest.ItemChanges[0] = new ItemChangeType(); updateItemRequest.ItemChanges[0].Item = occurrenceId; SetItemFieldType setItemField = new SetItemFieldType(); PathToUnindexedFieldType pathToUnindexed = new PathToUnindexedFieldType(); pathToUnindexed.FieldURI = UnindexedFieldURIType.calendarLocation; setItemField.Item = pathToUnindexed; setItemField.Item1 = new CalendarItemType() { Location = this.LocationUpdate }; updateItemRequest.ItemChanges[0].Updates = new ItemChangeDescriptionType[] { setItemField }; UpdateItemResponseType updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest); Common.CheckOperationSuccess(updateItemResponse, 1, this.Site); #endregion #region Organizer gets the udpated calendar item calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", meetingItem.UID) as CalendarItemType; #endregion #region Organizer updates the calendar item updateItemRequest.ItemChanges[0].Item = calendar.ItemId; string locationUpdated = Common.GenerateResourceName(this.Site, "NewLocation"); setItemField.Item1 = new CalendarItemType() { Location = locationUpdated }; updateItemRequest.ItemChanges[0].Updates = new ItemChangeDescriptionType[] { setItemField }; updateItemResponse = this.MTGSAdapter.UpdateItem(updateItemRequest); Common.CheckOperationSuccess(updateItemResponse, 1, this.Site); #endregion #region Attendee gets the updated meeting request request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.inbox, locationUpdated, meetingItem.UID, UnindexedFieldURIType.calendarLocation) as MeetingRequestMessageType; // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R345"); // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R345 this.Site.CaptureRequirementIfAreEqual<int>( 1, request.ModifiedOccurrences.Length, 345, @"[In t:MeetingRequestMessageType Complex Type] ModifiedOccurrences: Contains an array of recurring meeting item occurrences that have been modified so that they are different from the original instances of the recurrence master item."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R347"); // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R347 this.Site.CaptureRequirementIfAreEqual<int>( 1, request.DeletedOccurrences.Length, 347, @"[In t:MeetingRequestMessageType Complex Type] DeletedOccurrences: Contains an array of deleted occurrences of a recurring meeting item."); #endregion #region Attendee gets the accepted meeting request again. request = this.SearchSingleItem(Role.Attendee, DistinguishedFolderIdNameType.deleteditems, "IPM.Schedule.Meeting.Request", meetingItem.UID) as MeetingRequestMessageType; Site.Assert.IsNotNull(request, "The meeting request should exist in attendee's Deleted Items folder after attendee accepts the meeting request."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R750"); // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R750 this.Site.CaptureRequirementIfIsTrue( request.IsOutOfDate, 750, @"[In t:MeetingMessageType Complex Type] [IsOutOfDate is] True, there has been an update to the meeting and the current item in the calendar is out of date."); #endregion #region Clean up organizer's deleteditems and sentitems folder, and attendee's inbox, calendar and deleteditems folders. this.CleanupFoldersByRole(Role.Organizer, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.sentitems, DistinguishedFolderIdNameType.deleteditems }); this.CleanupFoldersByRole(Role.Attendee, new List<DistinguishedFolderIdNameType>() { DistinguishedFolderIdNameType.inbox, DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.deleteditems }); #endregion }
/// <summary> /// Deletes all items and sub folders from the specified folder. /// </summary> /// <param name="folderName">Name of the specified parent folder.</param> /// <param name="needVerify">If need to verify the subfolders,when false,it will cleanup all the folders without verify</param> /// <returns>If the specified folder is cleaned up successfully, return true; otherwise, return false.</returns> private bool CleanupFolder(DistinguishedFolderIdNameType folderName, bool needVerify = true) { bool isAllItemsAndFoldersDeleted = false; ItemType[] items = this.FindAllItems(folderName); // Create a request for the DeleteItem operation. DeleteItemType deleteItemRequest = new DeleteItemType(); // The item is permanently removed from the store. deleteItemRequest.DeleteType = DisposalType.HardDelete; // Do not send meeting cancellations. deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemRequest.SendMeetingCancellationsSpecified = true; if (items != null) { foreach (ItemType currentItem in items) { if (currentItem.GetType() == typeof(TaskType)) { deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.AllOccurrences; } deleteItemRequest.ItemIds = new BaseItemIdType[] { currentItem.ItemId }; // Invoke the delete item operation. DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); Site.Assert.AreEqual<ResponseClassType>( ResponseClassType.Success, response.ResponseMessages.Items[0].ResponseClass, "The delete item operation should execute successfully."); } } // Find all sub folders in the specified folder. BaseFolderType[] folders = this.FindAllSubFolders(folderName); if (folders.Length != 0) { foreach (BaseFolderType currentFolder in folders) { if (needVerify) { bool isCreatedByCase = false; AdapterHelper.CreatedFolders.ForEach(r => { if (r.FolderId.Id == currentFolder.FolderId.Id) { isCreatedByCase = true; } }); if (!isCreatedByCase) { continue; } } FolderIdType responseFolderId = currentFolder.FolderId; FolderIdType folderId = new FolderIdType(); folderId.Id = responseFolderId.Id; DeleteFolderType deleteFolderRequest = new DeleteFolderType(); deleteFolderRequest.DeleteType = DisposalType.HardDelete; deleteFolderRequest.FolderIds = new BaseFolderIdType[1]; deleteFolderRequest.FolderIds[0] = folderId; // Send the request and get the response. DeleteFolderResponseType deleteFolderResponse = this.exchangeServiceBinding.DeleteFolder(deleteFolderRequest); // Delete folder operation should return response info. if (deleteFolderResponse.ResponseMessages.Items[0] != null) { Site.Assert.AreEqual<ResponseClassType>( ResponseClassType.Success, deleteFolderResponse.ResponseMessages.Items[0].ResponseClass, "The delete folder operation should be successful."); } } } // Invoke the FindItem operation. items = this.FindAllItems(folderName); // Invoke the FindFolder operation. folders = this.FindAllSubFolders(folderName); // If neither items and sub folders could be found, the folder has been cleaned up successfully. bool allFoldersBelongstoSys = true; foreach (BaseFolderType folder in folders) { bool find = false; AdapterHelper.CreatedFolders.ForEach(r => { if (r.FolderId.Id == folder.FolderId.Id) { find = true; } }); if (find) { allFoldersBelongstoSys = false; break; } } if (items == null && (folders.Length == 0 || allFoldersBelongstoSys)) { isAllItemsAndFoldersDeleted = true; } return isAllItemsAndFoldersDeleted; }
/// <summary> /// Log on to a mailbox with a specified user account and find the specified item then delete it. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="userPassword">Password of the user.</param> /// <param name="userDomain">Domain of the user.</param> /// <param name="folderName">Name of the folder which should be searched for the specified item.</param> /// <param name="itemSubject">Subject of the item which should be deleted.</param> /// <param name="itemType">Type of the item which should be deleted.</param> /// <returns>If the specified item is deleted successfully, return true; otherwise, return false.</returns> public bool FindAndDeleteItem(string userName, string userPassword, string userDomain, string folderName, string itemSubject, string itemType) { // Switch to specified user mailbox. bool isSwitched = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site); Site.Assert.IsTrue( isSwitched, string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain)); // Parse the parent folder name to DistinguishedFolderIdNameType. DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true); Item item = (Item)Enum.Parse(typeof(Item), itemType, true); ItemType type = this.LoopToFindItem(parentFolderIdName, itemSubject, item); bool isDeleted = false; if (type != null) { DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { type.ItemId }; // Invoke the delete item operation and get the response. DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); if (response != null && response.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { // If delete operation succeeds, return true isDeleted = true; } } return isDeleted; }
public void MSOXWSMSG_S03_TC02_CopyMessageUnsuccessful() { #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 Copy message deleted 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); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R170001"); this.Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Error, copyItemResponse.ResponseMessages.Items[0].ResponseClass, 170001, @"[In CopyItem] If the CreateItem WSDL operation is not successful, it returns a CreateItemResponse element with the ResponseClass attribute of the CreateItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R170002"); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), copyItemResponse.ResponseMessages.Items[0].ResponseCode), 170002, @"[In CopyItem] [A unsuccessful CopyItem operation request returns a CopyItemResponse element] The ResponseCode element of the CreateItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #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 }
public void MSOXWSCORE_S04_TC24_DeleteItemWithSuppressReadReceipts() { Site.Assume.IsTrue(Common.IsRequirementEnabled(2311, this.Site), "Exchange 2007, Exchange 2010, and the initial release of Exchange 2013 do not support the SuppressReadReceipts attribute."); #region Send an email with setting IsReadReceiptRequested to true. MessageType message = new MessageType(); message.IsReadReceiptRequestedSpecified = true; message.IsReadReceiptRequested = true; message.ToRecipients = new EmailAddressType[1]; EmailAddressType recipient = new EmailAddressType(); recipient.EmailAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site); message.ToRecipients[0] = recipient; message.From = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site) } }; CreateItemType createItemRequest = new CreateItemType(); createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new ItemType[] { message }; createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 1); createItemRequest.MessageDisposition = MessageDispositionType.SendOnly; createItemRequest.MessageDispositionSpecified = true; CreateItemResponseType createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Common.CheckOperationSuccess(createItemResponse, 1, this.Site); #endregion #region Find the email in receiver's inbox. ItemIdType[] findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2"); Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email."); #endregion #region Delete the found email with setting SuppressReadReceipts to true. DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = findItemIds; deleteItemRequest.DeleteType = DisposalType.HardDelete; deleteItemRequest.SuppressReadReceiptsSpecified = true; deleteItemRequest.SuppressReadReceipts = true; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1"); Site.Assert.IsNull(findItemIds, "The read receipt email should not be received if receiver delete the email with setting SuppressReadReceipts to true."); #endregion #region Send an email with setting IsReadReceiptRequested to true. createItemRequest.Items.Items[0].Subject = Common.GenerateResourceName(this.Site, TestSuiteHelper.SubjectForCreateItem, 2); createItemResponse = this.COREAdapter.CreateItem(createItemRequest); Common.CheckOperationSuccess(createItemResponse, 1, this.Site); #endregion #region Find the email in receiver's inbox. findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User2"); Site.Assert.IsNotNull(findItemIds, "The receiver should receive the email."); #endregion #region Delete the found email with setting SuppressReadReceipts to false. deleteItemRequest.ItemIds = findItemIds; deleteItemRequest.SuppressReadReceipts = false; deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); findItemIds = this.FindItemsInFolder(DistinguishedFolderIdNameType.inbox, createItemRequest.Items.Items[0].Subject, "User1"); Site.Assert.AreEqual<int>(1, findItemIds.Length, "The read receipt email should be received if receiver delete the email with setting SuppressReadReceipts to false."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2311"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2311 // This requirement can be captured directly after above steps. this.Site.CaptureRequirement( 2311, @"[In Appendix C: Product Behavior] Implementation does support the SuppressReadReceipts attribute which specifies whether read receipts are suppressed. (Exchange 2013 SP1 and above follow this behavior.)"); #endregion }
public void MSOXWSMSG_S01_TC07_GetMessageWithFilterHtmlContent() { Site.Assume.IsTrue(Common.GetConfigurationPropertyValue("SutVersion", this.Site).Equals("ExchangeServer2007") == false, "Exchange 2007 does not use the FilterHtmlContent element."); #region Create a message with html body #region Define a CreateItem request string unsafeHtmlContent = "<html><body><b>Bold</b><script>alert('Alert!');</script></body></html>"; CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, // Define the message which contains all the elements except ReceivedBy and ReceivedRepresenting. Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { // Create a MessageType instance with all element. new MessageType { // Specify the recipient of the message. ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, // Specify the subject of message. Subject = this.Subject, Body = new BodyType() { BodyType1 = BodyTypeType.HTML, Value = unsafeHtmlContent, } } } }, }; #endregion 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); #endregion #region Get the created message via itemIdType in above steps #region Send the GetItem requst which the FilterHtmlContent is set true. GetItemType getItemRequest = new GetItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, FilterHtmlContent = true, FilterHtmlContentSpecified = true, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), "The response of the GetItem should be valid."); MessageType message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R21193"); this.Site.CaptureRequirementIfIsFalse( message.Body.Value.Contains("<script>alert('Alert!');</script>"), "MS-OXWSCDATA", 21193, @"[In t:ItemResponseShapeType Complex Type] [FilterHtmlContent is] True, specifies HTML content filtering is enabled."); #endregion #region Send the GetItem requst which the FilterHtmlContent is set false. getItemRequest.ItemShape.FilterHtmlContent = false; getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages."); message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R21194"); this.Site.CaptureRequirementIfIsTrue( message.Body.Value.Contains("<script>alert('Alert!');</script>"), "MS-OXWSCDATA", 21194, @"[In t:ItemResponseShapeType Complex Type] otherwise [FilterHtmlContent is] false, specifies [HTML content filtering is not enabled]."); #endregion #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 }
/// <summary> /// Deletes items on the server. /// </summary> /// <param name="deleteItemRequest">Request message of "DeleteItem" operation.</param> /// <returns>Response message of "DeleteItem" operation.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); return deleteItemResponse; }
public void MSOXWSMSG_S01_TC01_CreateGetDeleteMessageWithAllElementsExceptAboutDelegate() { #region Create a message with all elements except ReceivedBy and ReceivedRepresenting elements #region Define a CreateItem request CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, // Define the message which contains all the elements except ReceivedBy and ReceivedRepresenting. Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { // Create a MessageType instance with all element. new MessageType { // Specify the recipient of the message. ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, // Specify the recipient that receives a carbon copy of the message. CcRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } }, // Specify the recipient that receives a blind carbon copy of the message. BccRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.MeetingRoom } }, // Specify the subject of message. Subject = this.Subject, // The sender of message requests a read receipt. IsReadReceiptRequested = true, IsReadReceiptRequestedSpecified = true, // The sender of message requests a delivery receipt. IsDeliveryReceiptRequested = true, IsDeliveryReceiptRequestedSpecified = true, // Response to the message is requested. IsResponseRequested = true, IsResponseRequestedSpecified = true, // Specify the address to which replies should be sent. ReplyTo = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } }, // Specify the Usenet header that is used to correlate replies with their original message. References = this.MsgReference, IsRead = true, IsReadSpecified = true, } } }, }; #endregion 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); #endregion #region Verify the requirements about CreateItem operation // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R111"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R111 Site.CaptureRequirementIfIsNotNull( createItemResponse, 111, @"[In CreateItem] The protocol client sends a CreateItemSoapIn request WSDL message, and the protocol server responds with a CreateItemSoapOut response WSDL message."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R112"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R112 Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 112, @"[In CreateItem]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"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R113"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R113 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 113, @"[In CreateItem] [A successful CreateItem operation request returns a CreateItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element is set to ""NoError"". "); #endregion #region Get the created message via itemIdType in above steps #region The getItemResponseOfFirstMessage is used to store the getItemResponseOfFirstMessage gotten from server when the BaseShape element is set to IdOnly. GetItemType getItemRequest = DefineGeneralGetItemRequestMessage(this.firstItemOfFirstInfoItem.ItemId, DefaultShapeNamesType.IdOnly); GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), "The response of the GetItem should be valid."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R127"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R127 bool isVerifyR127 = Common.IsIdOnly((XmlElement)this.MSGAdapter.LastRawResponseXml, "t:Message", "t:ItemId"); Site.CaptureRequirementIfIsTrue( isVerifyR127, 127, @"[In GetItem] [The BaseShape child element in ItemShape element] Set this element[BaseShape element] to IdOnly to return only the item ID."); #endregion #region The getItemResponseOfFirstMessage is used to store the getItemResponseOfFirstMessage got from server when the BaseShape element is set to AllProperties. getItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties; 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."); MessageType messageItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0) as MessageType; Site.Assert.IsNotNull(messageItem, @"The message item returned from server response should not be null."); #region Verify requirements about GetItem operation // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R133"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R133 Site.CaptureRequirementIfIsNotNull( getItemResponse, 133, @"[In GetItem] The protocol client sends a GetItemSoapIn request WSDL message, and the protocol server responds with a GetItemSoapOut response WSDL message."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R134"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R134 Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 134, @"[In GetItem] If the GetItem WSDL operation request is successful, the server returns a GetItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.4.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the GetItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R135"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R135 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 135, @"[In GetItem] [A successful GetItem operation request returns a GetItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the GetItemResponseMessage element is set to ""NoError"". "); bool isVerifiedR198 = Common.IsIdOnly((XmlElement)this.MSGAdapter.LastRawResponseXml, "t:Message", "t:ItemId"); this.Site.CaptureRequirementIfIsFalse( isVerifiedR198, 198, @"[In GetItem] [The BaseShape child element in ItemShape element] Set it[BaseShape element] to AllProperties to return all of the properties used by the server to construct a message."); #endregion #region Verify the child elements of the MessageType // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R2916, expected the length of EmailAddress is greater than zero, actual length is {0}", messageItem.ToRecipients[0].EmailAddress.Length); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R2916 // The type of the EmailAddress is verified in adapter capture code, only need to check whether this string has a minimum of one character. this.Site.CaptureRequirementIfIsTrue( messageItem.ToRecipients[0].EmailAddress.Length > 0, 2916, @"[In t:MessageType Complex Type] When the Mailbox element of ToRecipients element include an EmailAddress element of t:NonEmptyStringType, the t:NonEmptyStringType simple type specifies a string that MUST have a minimum of one character."); if (Common.IsRequirementEnabled(1428001, this.Site)) { this.Site.CaptureRequirementIfAreEqual<MailboxTypeType>( MailboxTypeType.Mailbox, messageItem.ToRecipients[0].MailboxType, 2912, @"[In t:MessageType Complex Type]When the Mailbox element of ToRecipients element include an MailboxType element of t:MailboxTypeType, the value ""Mailbox"" of t:MailboxTypeType specifies a mail-enabled directory service object."); } Site.Assert.AreEqual<string>(this.Recipient1.ToLower(), messageItem.ToRecipients[0].EmailAddress.ToLower(), "The EmailAddress of the ToRecipients element in GetItem response should be equal with the settings"); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R30"); // Each user has his own EmailAddress, if the above assert is passed, the following requirements can be captured directly. this.Site.CaptureRequirement( 30, @"[In t:MessageType Complex Type] ToRecipients element Specifies a collection of recipients of an email."); Site.Assert.AreEqual<string>(this.Recipient2.ToLower(), messageItem.CcRecipients[0].EmailAddress.ToLower(), "The EmailAddress of the CcRecipients element in GetItem response should be equal with the settings"); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R33"); // Each user has his own EmailAddress, if the above assert is passed, the following requirements can be captured directly. this.Site.CaptureRequirement( 33, @"[In t:MessageType Complex Type] CcRecipients element Specifies a collection of recipients that receive a carbon copy (Cc) of an email."); Site.Assert.AreEqual<string>(this.MeetingRoom.ToLower(), messageItem.BccRecipients[0].EmailAddress.ToLower(), "The EmailAddress of the BccRecipients element in GetItem response should be equal with the settings"); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R36"); // Each user has his own EmailAddress, if the above assert is passed, the following requirements can be captured directly. this.Site.CaptureRequirement( 36, @"[In t:MessageType Complex Type] BccRecipients element Specifies a collection of recipients that receive a blind carbon copy (Bcc) of an email."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R42"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R42 this.Site.CaptureRequirementIfIsTrue( messageItem.IsReadReceiptRequested, 42, @"[In t:MessageType Complex Type] [IsReadReceiptRequested element] A text value of ""true"" indicates that a read receipt is requested from the recipient of the message."); // If the R42 is verified, then the IsReadReceiptRequested is a boolean and it indicates that a read receipt is requested from the recipient of the message. // So the R39 will be verified. this.Site.CaptureRequirement( 39, @"[In t:MessageType Complex Type] IsReadReceiptRequested element Specifies a Boolean value that indicates whether the sender of a message requests a read receipt."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R46"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R46 this.Site.CaptureRequirementIfIsTrue( messageItem.IsDeliveryReceiptRequested, 46, @"[In t:MessageType Complex Type] [IsDeliveryReceiptRequested element] A text value of ""true"" indicates that a delivery receipt has been requested from the recipient of the message."); // If the R46 is verified, then the IsDeliveryReceiptRequested is a boolean and it indicates that a delivery receipt has been requested from the recipient of the message. // So the R43 will be verified. this.Site.CaptureRequirement( 43, @"[In t:MessageType Complex Type] IsDeliveryReceiptRequested element Specifies a Boolean value that indicates whether the sender of the message has requested a delivery receipt."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R61"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R61 this.Site.CaptureRequirementIfIsTrue( messageItem.IsRead, 61, @"[In t:MessageType Complex Type] [IsRead element]The text value of ""true"" indicates that the message has been read."); // If R61 is verified, then the IsRead is boolean and it indicates that the message has been read. // So the R59 will be verified. this.Site.CaptureRequirement( 59, @"[In t:MessageType Complex Type] IsRead element Specifies a Boolean value that indicates whether the message has been read."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R65"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R65 this.Site.CaptureRequirementIfIsTrue( messageItem.IsResponseRequested, 65, @"[In t:MessageType Complex Type] [IsResponseRequested element] A text value of ""true"" indicates that a response has been requested."); // If R65 is verified, then the IsResponseRequested is boolean and it indicates that a response has been requested. // So R62 will be verified. this.Site.CaptureRequirement( 62, @"[In t:MessageType Complex Type] IsResponseRequested element Specifies a Boolean value that indicates whether a response to an email has been requested."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R66"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R66 this.Site.CaptureRequirementIfAreEqual<string>( this.MsgReference, messageItem.References, 66, @"[In t:MessageType Complex Type] References element Specifies the Usenet header that is used to correlate replies with their original message."); Site.Assert.AreEqual<string>(this.Recipient2.ToLower(), messageItem.ReplyTo[0].EmailAddress.ToLower(), "The EmailAddress of the From element in GetItem response should be equal to the settings"); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R69"); // Each user has his own EmailAddress, if the above assert is passed, the following requirements can be captured directly. this.Site.CaptureRequirement( 69, @"[In t:MessageType Complex Type] ReplyTo element Specifies a collection of addresses to send replies to. "); #endregion #region Verify the requirements about the read/write element of MessageType // The messageRequest is used to save the message in request to create. MessageType messageRequest = createItemRequest.Items.Items[0] as MessageType; Site.Assert.IsNotNull(messageRequest, @"The CreateItem request should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R32"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R32 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the ToRecipients value from getItem response is equal to the setting ToRecipients element value in createItem request. Site.CaptureRequirementIfAreEqual<string>( messageRequest.ToRecipients[0].EmailAddress.ToLower(), messageItem.ToRecipients[0].EmailAddress.ToLower(), 32, @"[In t:MessageType Complex Type] [ToRecipients element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R35"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R35 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the CcRecipients value from getItem response is equal to the setting CcRecipients element value in createItem request. Site.CaptureRequirementIfAreEqual<string>( messageRequest.CcRecipients[0].EmailAddress.ToLower(), messageItem.CcRecipients[0].EmailAddress.ToLower(), 35, @"[In t:MessageType Complex Type] [CcRecipients element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R38"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R38 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the BccRecipients value from getItem response is equal to the setting BccRecipients element value in createItem request. Site.CaptureRequirementIfAreEqual<string>( messageRequest.BccRecipients[0].EmailAddress.ToLower(), messageItem.BccRecipients[0].EmailAddress.ToLower(), 38, @"[In t:MessageType Complex Type] [BccRecipients element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R41"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R41 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the IsReadReceiptRequested value from getItem response is equal to the setting IsReadReceiptRequested element value in createItem request. Site.CaptureRequirementIfAreEqual<bool>( messageRequest.IsReadReceiptRequested, messageItem.IsReadReceiptRequested, 41, @"[In t:MessageType Complex Type] [IsReadReceiptRequested element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R45"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R45 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the IsDeliveryReceiptRequested value from getItem response is equal to the setting IsDeliveryReceiptRequested element value in createItem request. Site.CaptureRequirementIfAreEqual<bool>( messageRequest.IsDeliveryReceiptRequested, messageItem.IsDeliveryReceiptRequested, 45, @"[In t:MessageType Complex Type] [IsDeliveryReceiptRequested element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R64"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R64 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the IsResponseRequested value from getItem response is equal to the setting IsResponseRequested element value in createItem request. Site.CaptureRequirementIfAreEqual<bool>( messageRequest.IsResponseRequested, messageItem.IsResponseRequested, 64, @"[In t:MessageType Complex Type] [IsResponseRequested element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R68"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R68 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the References value from getItem response is equal to the setting References element value in createItem request. Site.CaptureRequirementIfAreEqual<string>( messageRequest.References, messageItem.References, 68, @"[In t:MessageType Complex Type] [References element] This is a read/write element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R71"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R71 // This requirement can be verified since the createItem response message succeeded which indicates message was created successfully // and the ReplyTo value from getItem response is equal to the setting ReplyTo element value in createItem request. Site.CaptureRequirementIfAreEqual<string>( messageRequest.ReplyTo[0].EmailAddress.ToLower(), messageItem.ReplyTo[0].EmailAddress.ToLower(), 71, @"[In t:MessageType Complex Type] [ReplyTo element] This is a read/write element."); this.Site.CaptureRequirementIfAreEqual<bool>( messageRequest.IsRead, messageItem.IsRead, 60, @"[In t:MessageType Complex Type] [IsRead element] This is a read/write element."); #endregion #endregion #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."); GetItemType getdeletedItemRequest = DefineGeneralGetItemRequestMessage(this.firstItemOfFirstInfoItem.ItemId, DefaultShapeNamesType.IdOnly); GetItemResponseType getdeletedItemResponse = this.MSGAdapter.GetItem(getdeletedItemRequest); // verify whether the creating message deleted if (getdeletedItemResponse != null && getdeletedItemResponse.ResponseMessages != null && getdeletedItemResponse.ResponseMessages.Items != null) { if (getdeletedItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { Site.Assert.Fail("Server should not return success for get the email messages information, because the created message have been deleted."); } } #region Verify requirements about DeleteItem operation // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R152"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R152 Site.CaptureRequirementIfIsNotNull( deleteItemResponse, 152, @"[In DeleteItem] The protocol client sends a DeleteItemSoapIn request WSDL message, and the protocol server responds with a DeleteItemSoapOut response WSDL message."); Site.Assert.IsNotNull(deleteItemResponse.ResponseMessages.Items[0], @"The first item of the array of InfoItems in server response should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R153"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R153 Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, deleteItemResponse.ResponseMessages.Items[0].ResponseClass, 153, @"[In DeleteItem] If the DeleteItem WSDL operation request is successful, the server returns a DeleteItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.3.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the DeleteItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(deleteItemResponse.ResponseMessages.Items[0].ResponseCode, @"The ResponseCode property of the first item of the array of InfoItems should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R154"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R154 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.NoError, deleteItemResponse.ResponseMessages.Items[0].ResponseCode, 154, @"[In DeleteItem] [A successful DeleteItem operation request returns a DeleteItemResponse element] The ResponseCode element, as specified by [MS-OXWSCDATA] section 2.2.4.67, of the DeleteItemResponseMessage element is set to ""NoError"". "); #endregion #endregion }
/// <summary> /// Delete a specific message. /// </summary> /// <param name="messageId">The Id of the message to be deleted.</param> /// <returns>True if the delete operation success, otherwise false.</returns> protected bool DeleteMessage(string messageId) { DeleteItemType deleteItemRequest = new DeleteItemType() { DeleteType = DisposalType.HardDelete, ItemIds = new BaseItemIdType[] { new ItemIdType() { Id = messageId } } }; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); ResponseMessageType responseMessage = deleteItemResponse.ResponseMessages.Items[0] as ResponseMessageType; return responseMessage.ResponseClass == ResponseClassType.Success; }
public void MSOXWSMSG_S01_TC06_GetMessageWithIncludeMimeContent() { #region Create a message #region Define a CreateItem request CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, // Define the message which contains all the elements except ReceivedBy and ReceivedRepresenting. Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { // Create a MessageType instance with all element. new MessageType { // Specify the recipient of the message. ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, // Specify the subject of message. Subject = this.Subject, } } }, }; #endregion 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); #endregion #region Get the created message via itemIdType in above steps #region Send the GetItem requst which the IncludeMimeContent is set true. GetItemType getItemRequest = new GetItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, IncludeMimeContent = true, IncludeMimeContentSpecified = true, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), "The response of the GetItem should be valid."); MessageType message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R21188"); this.Site.CaptureRequirementIfIsNotNull( message.MimeContent, "MS-OXWSCDATA", 21188, @"[In t:ItemResponseShapeType Complex Type] [IncludeMimeContent is] True, specifies the MIME content of an item is returned in a response."); #endregion #region Send the GetItem requst which the IncludeMimeContent is set false. getItemRequest.ItemShape.IncludeMimeContent = false; getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyResponse(getItemResponse), @"Server should return success for getting the email messages."); message = ((ItemInfoResponseMessageType)getItemResponse.ResponseMessages.Items[0]).Items.Items[0] as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R21189"); this.Site.CaptureRequirementIfIsNull( message.MimeContent, "MS-OXWSCDATA", 21189, @"[In t:ItemResponseShapeType Complex Type] otherwise [IncludeMimeContent is] false, specifies [the MIME content of an item is not returned in a response]."); #endregion #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 }
/// <summary> /// Delete items on the server. /// </summary> /// <param name="deleteItemRequest">Specify a request to delete item on the server.</param> /// <returns>A response to DeleteItem operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null."); // SOAP version is set to 1.1, if a response can be received from server, then it means SOAP 1.1 is supported. this.VerifySoapVersion(); // Verify transport type related requirement. this.VerifyTransportType(); this.VerifyServerVersionInfo(this.exchangeServiceBinding.ServerVersionInfoValue, this.exchangeServiceBinding.IsSchemaValidated); this.VerifyDeleteItemResoponse(response, this.exchangeServiceBinding.IsSchemaValidated); return response; }
public void MSOXWSCONT_S01_TC01_VerifyContactItemWithRequiredElement() { #region Step 1:Create the contact item. // Call CreateItem operation. ContactItemType item = this.BuildContactItemWithRequiredProperties(); CreateItemResponseType createItemResponse = this.CallCreateItemOperation(item); // Check the response. Common.CheckOperationSuccess(createItemResponse, 1, this.Site); #endregion #region Step 2:Get the contact item. // The contact item to get. ItemIdType[] itemArray = new ItemIdType[this.ExistContactItems.Count]; this.ExistContactItems.CopyTo(itemArray, 0); GetItemResponseType getItemResponse = this.CallGetItemOperation(itemArray); // Check the response. Common.CheckOperationSuccess(getItemResponse, 1, this.Site); // Get the item ids from response. ItemIdType[] getItemIds = Common.GetItemIdsFromInfoResponse(getItemResponse); Site.Assert.AreEqual<int>( 1, getItemIds.GetLength(0), "One contact item should be returned!"); #endregion #region Step 3:Delete the contact item. DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = getItemIds; // Configure the enumeration value that specifies how an contact item is to be deleted. deleteItemRequest.DeleteType = DisposalType.HardDelete; DeleteItemResponseType deleteItemResponse = this.CONTAdapter.DeleteItem(deleteItemRequest); // Check the response. Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); // Clear ExistItemIds for DeleteItem. this.InitializeCollection(); #endregion #region Step 4:Get the deleted contact item // Call GetItem operation. getItemResponse = this.CallGetItemOperation(getItemIds); Site.Assert.AreEqual<int>( 1, getItemResponse.ResponseMessages.Items.GetLength(0), "Expected Item Count: {0}, Actual Item Count: {1}", 1, getItemResponse.ResponseMessages.Items.GetLength(0)); Site.Assert.AreEqual<ResponseCodeType>( ResponseCodeType.ErrorItemNotFound, getItemResponse.ResponseMessages.Items[0].ResponseCode, string.Format( "Get deleted item should fail! Expected response code: {0}, actual response code: {1}", ResponseCodeType.ErrorItemNotFound, getItemResponse.ResponseMessages.Items[0].ResponseCode)); #endregion }
/// <summary> /// Delete the calendar related item elements. /// </summary> /// <param name="request">A request to the DeleteItem operation.</param> /// <returns>The response message returned by DeleteItem operation.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType request) { if (request == null) { throw new ArgumentException("The request of operation 'DeleteItem' should not be null."); } DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(request); this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyDeleteItemOperation(this.exchangeServiceBinding.IsSchemaValidated); return deleteItemResponse; }
/// <remarks/> public System.IAsyncResult BeginDeleteItem(DeleteItemType DeleteItem1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("DeleteItem", new object[] { DeleteItem1}, callback, asyncState); }
/// <summary> /// Delete specific item. /// </summary> /// <param name="itemId">Id of specific item.</param> /// <returns>If specific item deleted successfully.</returns> protected bool DeleteItem(ItemIdType itemId) { // If id is null return false. if (itemId == null) { return false; } DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.AllOccurrences; deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemRequest.SendMeetingCancellationsSpecified = true; // Serialize item ids and change keys to ItemIdType arrays. ItemIdType[] itemIdTypes = new ItemIdType[1]; itemIdTypes[0] = itemId; deleteItemRequest.ItemIds = itemIdTypes; deleteItemRequest.DeleteType = DisposalType.HardDelete; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); return deleteItemResponse.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError; }
/// <remarks/> public void DeleteItemAsync(DeleteItemType DeleteItem1, object userState) { if ((this.DeleteItemOperationCompleted == null)) { this.DeleteItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteItemOperationCompleted); } this.InvokeAsync("DeleteItem", new object[] { DeleteItem1}, this.DeleteItemOperationCompleted, userState); }
/// <summary> /// Delete items on the server. /// </summary> /// <param name="deleteItemRequest">Specify a request to delete item on the server.</param> /// <returns>A response to this operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { if (deleteItemRequest == null) { throw new ArgumentException("The DeleteItem request should not be null."); } DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); return response; }