Microsoft.Protocols.TestSuites.MS_OXWSCORE.S01_ManageBaseItems.MSOXWSCORE_S01_TC21_GetItemWithNormalizedBodyEnums C# (CSharp) Method

MSOXWSCORE_S01_TC21_GetItemWithNormalizedBodyEnums() private method

        public void MSOXWSCORE_S01_TC21_GetItemWithNormalizedBodyEnums()
        {
            bool isNormalizedBodySupported = Common.IsRequirementEnabled(1349, this.Site) && Common.IsRequirementEnabled(1683, this.Site);
            Site.Assume.IsTrue(isNormalizedBodySupported, "Exchange 2007 and Exchange 2010 do not support the NormalizedBody 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.itemNormalizedBody
                    }
                };

                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].NormalizedBody, "The NormalizedBody element of the item should not be null, actual: {0}.", getItems[0].NormalizedBody);

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

            #region Step 3: Verify the NormalizedBody element.

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

            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1349
            this.Site.CaptureRequirementIfAreEqual<BodyTypeType>(
                BodyTypeType.HTML,
                items[0].NormalizedBody.BodyType1,
                1349,
                @"[In Appendix C: Product Behavior] Implementation does support value ""HTML"" of ""NormalizedBody"" which specifies the item body as HTML content. (Exchange 2013 and above follow this behavior.)");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1683");
        
            // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1683
            this.Site.CaptureRequirementIfAreEqual<BodyTypeType>(
                BodyTypeType.Text,
                items[1].NormalizedBody.BodyType1,
                1683,
                @"[In Appendix C: Product Behavior] Implementation does support value ""Text"" of ""NormalizedBody"" which specifies the item body as text content. (Exchange 2013 and above follow this behavior.)");
            #endregion
        }
S01_ManageBaseItems