Microsoft.Protocols.TestSuites.MS_OXWSMSG.S01_CreateGetDeleteEmailMessage.MSOXWSMSG_S01_TC08_GetMessageWithBodyTypeAndAdditionProperties C# (CSharp) Method

MSOXWSMSG_S01_TC08_GetMessageWithBodyTypeAndAdditionProperties() private method

        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
        }
        #endregion