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
}