Microsoft.Protocols.TestSuites.MS_LISTSWS.S03_OperationOnListItem.MSLISTSWS_S03_TC04_AddDiscussionBoardItem_Success_ListNameIsInvalidGuid C# (CSharp) Method

MSLISTSWS_S03_TC04_AddDiscussionBoardItem_Success_ListNameIsInvalidGuid() private method

        public void MSLISTSWS_S03_TC04_AddDiscussionBoardItem_Success_ListNameIsInvalidGuid()
        {
            // Construct a ListName. It is an invalid Guid, but it corresponds to the list title of a list.
            string listName = TestSuiteHelper.GetUniqueListName();

            // Construct a template id.
            int discussionBoardTemplateId = (int)TemplateType.Discussion_Board;

            // Create a list by using specified list name and template Id.
            string listId = TestSuiteHelper.CreateList(listName, discussionBoardTemplateId);

            // Construct the value of the message for AddDiscussionBoardItem.
            byte[] message = TestSuiteHelper.GetMessageDataForAddDiscussionBoardItem();

            // Call AddDiscussionBoardItem to add new discussion items to a specified Discussion Board, 
            // with the ListName is an invalid Guid, but it exists on the server.
            AddDiscussionBoardItemResponseAddDiscussionBoardItemResult result = null;
            result = this.listswsAdapter.AddDiscussionBoardItem(listName, message);

            Site.Assert.IsNotNull(result, "AddDiscussionBoardItem operation is successful.");

            if (Common.IsRequirementEnabled(3101, this.Site))
            {
                // Verify requirement R3101.
                // If there is no assert fail, it means AddDiscussionBoardItem operation is successful. R3101 can be captured. 
                Site.CaptureRequirement(
                    3101,
                    @"Implementation does support this method[AddDiscussionBoardItem]. (Windows SharePoint Services 3.0 and above follow this behavior.)");
            }

            // Call GetListItems to retrieve details about list items in a list that satisfies specified criteria.           
            GetListItemsResponseGetListItemsResult getListItemsResult = null;
            getListItemsResult = this.listswsAdapter.GetListItems(
                                                                    listId,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null);

            // extract a row element to a DataTable, it is used for "z:row" data
            DataTable data = AdapterHelper.ExtractData(getListItemsResult.listitems.data.Any);

            #region Capture Requirements 316,317

            // If the value of ItemCount from the GetListItems operation is equal to 1, then the 
            // DiscussionBoardItem is added successfully, R315 and R320 should be covered.
            Site.CaptureRequirementIfAreEqual<int>(
                    1,
                    data.Rows.Count,
                    316,
                    @"[In AddDiscussionBoardItem operation] If the specified listName is not a valid "
                    + "GUID, check whether the listName corresponds to the list title of a list on the "
                    + "site and if so, use that list.");

            Site.CaptureRequirementIfAreEqual<int>(
                    1,
                    data.Rows.Count,
                    317,
                    @"[In AddDiscussionBoardItem operation] If the specified listName does not "
                    + "correspond to the ID of a list on the site, check whether the listName "
                    + "corresponds to the list title of a list on the site and if so, use that list.");

            #endregion
        }
S03_OperationOnListItem