Exemplo n.º 1
0
        /// <summary>
        /// Gets an attachment from an item.
        /// </summary>
        /// <param name="bodyType">Represents the format of the body text in a response.</param>
        /// <param name="includeMimeContent">Indicates whether the MIME content of an item or attachment is returned in a response. </param>
        /// <param name="attachmentIds">Contains the identifiers of the attachments to return in the response.</param>
        /// <returns>A response message for "GetAttachment" operation.</returns>
        protected GetAttachmentResponseType CallGetAttachmentOperation(BodyTypeResponseType bodyType, bool includeMimeContent, params AttachmentIdType[] attachmentIds)
        {
            GetAttachmentType getAttachmentRequest = new GetAttachmentType()
            {
                AttachmentIds = attachmentIds,

                AttachmentShape = new AttachmentResponseShapeType()
                {
                    BodyType                    = bodyType,
                    BodyTypeSpecified           = true,
                    IncludeMimeContent          = includeMimeContent,
                    IncludeMimeContentSpecified = true,
                    AdditionalProperties        = new BasePathToElementType[]
                    {
                        new PathToIndexedFieldType()
                        {
                            FieldURI   = DictionaryURIType.itemInternetMessageHeader,
                            FieldIndex = string.Empty
                        },
                        new PathToUnindexedFieldType()
                        {
                            FieldURI = UnindexedFieldURIType.itemDateTimeCreated
                        }
                    }
                }
            };

            return(this.ATTAdapter.GetAttachment(getAttachmentRequest));
        }
        /// <summary>
        /// Gets an attachment from an item.
        /// </summary>
        /// <param name="bodyType">Represents the format of the body text in a response.</param>
        /// <param name="includeMimeContent">Indicates whether the MIME content of an item or attachment is returned in a response. </param>
        /// <param name="attachmentIds">Contains the identifiers of the attachments to return in the response.</param>
        /// <returns>A response message for "GetAttachment" operation.</returns>
        protected GetAttachmentResponseType CallGetAttachmentOperation(BodyTypeResponseType bodyType, bool includeMimeContent, params AttachmentIdType[] attachmentIds)
        {
            GetAttachmentType getAttachmentRequest = new GetAttachmentType()
             {
                 AttachmentIds = attachmentIds,

                 AttachmentShape = new AttachmentResponseShapeType()
                 {
                     BodyType = bodyType,
                     BodyTypeSpecified = true,
                     IncludeMimeContent = includeMimeContent,
                     IncludeMimeContentSpecified = true,
                     AdditionalProperties = new BasePathToElementType[]
                    {
                        new PathToIndexedFieldType()
                        {
                             FieldURI = DictionaryURIType.itemInternetMessageHeader,
                             FieldIndex = string.Empty
                        },
                        new PathToUnindexedFieldType()
                        {
                            FieldURI = UnindexedFieldURIType.itemDateTimeCreated
                        }
                    }
                 }
             };

            return this.ATTAdapter.GetAttachment(getAttachmentRequest);
        }
        public void MSOXWSCORE_S01_TC25_GetItemWithUniqueBodyEnums()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2290, this.Site), "Exchange 2007 does not support the UniqueBody element.");

            // Define the count of enumerations.
            int enumCount = 2;
            BodyTypeResponseType[] bodyTypeResponseTypes = new BodyTypeResponseType[enumCount];

            bodyTypeResponseTypes[0] = BodyTypeResponseType.HTML;
            bodyTypeResponseTypes[1] = BodyTypeResponseType.Text;

            // Define an item array to store the items got from GetItem operation response.
            // Each item should contain a BodyTypeResponseType value as its element's value.
            ItemType[] items = new ItemType[enumCount];
            for (int i = 0; i < enumCount; i++)
            {
                BodyTypeResponseType bodyTypeType = bodyTypeResponseTypes[i];

                #region Step 1: Create the item.
                ItemType[] createdItems = new ItemType[] { new ItemType() };
                createdItems[0].Subject = Common.GenerateResourceName(
                    this.Site,
                    TestSuiteHelper.SubjectForCreateItem);

                CreateItemResponseType createItemResponse = this.CallCreateItemOperation(DistinguishedFolderIdNameType.drafts, createdItems);

                // Check the operation response.
                Common.CheckOperationSuccess(createItemResponse, 1, this.Site);

                ItemIdType[] createdItemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

                // One created item should be returned.
                Site.Assert.AreEqual<int>(
                     1,
                     createdItemIds.GetLength(0),
                     "One created item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                     1,
                     createdItemIds.GetLength(0));
                #endregion

                #region Step 2: Get the item.
                GetItemType getItem = new GetItemType();
                GetItemResponseType getItemResponse = new GetItemResponseType();

                // The Item properties returned
                getItem.ItemShape = new ItemResponseShapeType();
                getItem.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
                getItem.ItemShape.BodyType = bodyTypeType;
                getItem.ItemShape.BodyTypeSpecified = true;

                // The item to get
                getItem.ItemIds = createdItemIds;

                // Set additional properties.
                getItem.ItemShape.AdditionalProperties = new PathToUnindexedFieldType[]
                {
                    new PathToUnindexedFieldType()
                    { 
                        FieldURI = UnindexedFieldURIType.itemUniqueBody
                    }
                };

                getItemResponse = this.COREAdapter.GetItem(getItem);

                // Check the operation response.
                Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

                ItemType[] getItems = Common.GetItemsFromInfoResponse<ItemType>(getItemResponse);

                // One item should be returned.
                Site.Assert.AreEqual<int>(
                     1,
                     getItems.GetLength(0),
                     "One item should be returned! Expected Item Count: {0}, Actual Item Count: {1}",
                     1,
                     getItems.GetLength(0));

                Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated.");

                // Assert the NormalizedBody elements is not null.
                Site.Assert.IsNotNull(getItems[0].UniqueBody, "The UniqueBody element of the item should not be null, actual: {0}.", getItems[0].UniqueBody);

                items[i] = getItems[0];
                #endregion
            }

            #region Step 3: Verify the UniqueBody element.

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1681");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1681
            this.Site.CaptureRequirementIfAreEqual<BodyTypeType>(
                BodyTypeType.HTML,
                items[0].UniqueBody.BodyType1,
                1681,
                @"[In t:ItemType Complex Type] The value  ""HTML"" of ""UniqueBody"" specifies the item body as HTML content.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1682");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1682
            this.Site.CaptureRequirementIfAreEqual<BodyTypeType>(
                BodyTypeType.Text,
                items[1].UniqueBody.BodyType1,
                1682,
                @"[In t:ItemType Complex Type] The value ""Text"" of ""UniqueBody"" specifies the item body as text content.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R2290");

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R2290
            // The element UniqueBody is returned, so this requirement can be captured.
            this.Site.CaptureRequirement(
                2290,
                @"[In Appendix C: Product Behavior] Implementation does support the element ""UniqueBody"" which specifies the body part that is unique to the conversation that an item is part of. (Exchange 2010 and above follow this behavior.)");
            #endregion
        }