private BodyFormat Convert(BodyTypeType bodyType) { switch (bodyType) { case BodyTypeType.HTML: return(BodyFormat.TextHtml); case BodyTypeType.Text: return(BodyFormat.TextPlain); default: throw new InvalidContactException(); } }
public void MSOXWSCORE_S01_TC12_VerifyItemWithBodyEnums() { // Define the count of enumerations int enumCount = 2; BodyTypeType[] bodyTypeTypes = new BodyTypeType[enumCount]; bodyTypeTypes[0] = BodyTypeType.HTML; bodyTypeTypes[1] = BodyTypeType.Text; // Define an item array to store the items got from GetItem operation response. // Each item should contain a BodyTypeType value as its element's value ItemType[] items = new ItemType[enumCount]; for (int i = 0; i < enumCount; i++) { BodyTypeType bodyTypeType = bodyTypeTypes[i]; #region Step 1: Create the item. ItemType[] createdItems = new ItemType[] { new ItemType() }; createdItems[0].Subject = Common.GenerateResourceName( this.Site, TestSuiteHelper.SubjectForCreateItem); createdItems[0].Body = new BodyType(); createdItems[0].Body.Value = TestSuiteHelper.BodyForBaseItem; createdItems[0].Body.BodyType1 = bodyTypeType; 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. // Call the GetItem operation. GetItemResponseType getItemResponse = this.CallGetItemOperation(createdItemIds); // 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)); items[i] = getItems[0]; ItemInfoResponseMessageType getItemResponseMessage = getItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType; Site.Assert.IsTrue(this.IsSchemaValidated, "The schema should be validated."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1097"); // Verify MS-OXWSCORE requirement: MS-OXWSCDATA_R1097 this.Site.CaptureRequirementIfAreEqual<BodyTypeType>( bodyTypeType, getItemResponseMessage.Items.Items[0].Body.BodyType1, "MS-OXWSCDATA", 1097, @"[In t:BodyType Complex Type] The name ""BodyType"" with type ""t:BodyTypeType"" Specifies the body content and format of an item."); #endregion } // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1679"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1679 this.Site.CaptureRequirementIfAreEqual<BodyTypeType>( BodyTypeType.HTML, items[0].Body.BodyType1, 1679, @"[In t:ItemType Complex Type] The value ""HTML"" of ""Body"" specifies the item body as HTML content."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCORE_R1680"); // Verify MS-OXWSCORE requirement: MS-OXWSCORE_R1680 this.Site.CaptureRequirementIfAreEqual<BodyTypeType>( BodyTypeType.Text, items[1].Body.BodyType1, 1680, @"[In t:ItemType Complex Type] The value ""Text"" of ""Body"" specifies the item body as text content."); }