Microsoft.Protocols.TestSuites.MS_LISTSWS.S02_OperationOnContentType.MSLISTSWS_S02_TC70_UpdateContentTypesXmlDocument_WithListTitle_Succeed C# (CSharp) Method

MSLISTSWS_S02_TC70_UpdateContentTypesXmlDocument_WithListTitle_Succeed() private method

        public void MSLISTSWS_S02_TC70_UpdateContentTypesXmlDocument_WithListTitle_Succeed()
        {
            #region Add a list
            string listName = TestSuiteHelper.GetUniqueListName();

            string listId = TestSuiteHelper.CreateList(listName);

            bool isListCreatedSuccessful = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessful, "Creating list successfully.");

            #endregion Add a list

            #region CreateContentType
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            string fieldName = TestSuiteHelper.GetUniqueFieldName();
            List<string> fields = new List<string> { fieldName };

            string contextType = TestSuiteHelper.CreateContentType(listId, displayName, fields);
            this.Site.Assert.IsTrue(!string.IsNullOrEmpty(contextType), "Calling CreateContentType successfully.");
            #endregion CreateContentType

            #region  UpdateContentTypesXmlDocument
            // Construct the newDocument parameter for the invocation below.
            UpdateContentTypesXmlDocumentNewDocument newDocument = new UpdateContentTypesXmlDocumentNewDocument();
            newDocument.ContentTypes = new UpdateContentTypesXmlDocumentNewDocumentContentType[1];
            string qualifiedNameOne = TestSuiteHelper.GetUniqueFieldName();
            string namespaceURIOne = Common.GetConfigurationPropertyValue("ContentTypeXmlNamespaceUri", this.Site);
            string innerXmlOne = Common.GetConfigurationPropertyValue("ValidContentTypeXmlDocument", this.Site);

            newDocument.ContentTypes[0] = new UpdateContentTypesXmlDocumentNewDocumentContentType();
            newDocument.ContentTypes[0].ID = contextType;

            XmlDocument doc = new XmlDocument();

            newDocument.ContentTypes[0].Any = doc.CreateElement(qualifiedNameOne, namespaceURIOne);
            newDocument.ContentTypes[0].Any.InnerXml = innerXmlOne;

            UpdateContentTypesXmlDocumentResponseUpdateContentTypesXmlDocumentResult updateContentTypesXmlDocumentResult
                = this.listswsAdapter.UpdateContentTypesXmlDocument(listName, newDocument);

            Site.CaptureRequirementIfIsNotNull(
                updateContentTypesXmlDocumentResult,
                857,
                @"[In UpdateContentTypesXmlDocument operation] [In UpdateContentTypesXmlDocumentResponse element] [In UpdateContentTypesXmlDocumentResult element] If no error conditions cause the protocol server to return a SOAP fault, an UpdateContentTypesXmlDocumentResult MUST be returned.");

            // If the list whose list title corresponds to the specified listName exists and it is updated successfully, the server will return a successful response.
            // So if the response of the operation isn't null, then capture R844, R845, R848 and R2278.
            Site.CaptureRequirementIfIsNotNull(
                updateContentTypesXmlDocumentResult,
                844,
                @"[In UpdateContentTypesXmlDocument operation] If the specified listName is not a valid GUID, check if the listName corresponds to the list title of a list on the site and, if so, use that list.");

            Site.CaptureRequirementIfIsNotNull(
                updateContentTypesXmlDocumentResult,
                845,
                @"[In UpdateContentTypesXmlDocument operation] If the specified listName does not correspond to the identification of a list on the site, check if the listName corresponds to the list title of a list on the site and, if so, use that list.");

            Site.CaptureRequirementIfIsNotNull(
                updateContentTypesXmlDocumentResult,
                848,
                @"[In UpdateContentTypesXmlDocument operation] Otherwise [If the newDocument follows the schema, the content type specified by the ContentType.ID attribute contains child elements, the specified listName corresponds to the identification or the list title of a list on the site and there is no XML document with the same namespace URI exist], the new XML Document MUST be added to the XML document collection that the content type specified by the ContentType.ID attribute.");

            Site.CaptureRequirementIfIsNotNull(
                updateContentTypesXmlDocumentResult,
                2278,
                @"[In UpdateContentTypesXmlDocument operation] Otherwise [If the newDocument follows the schema, the content type specified by the ContentType.ID attribute contains child elements, the specified listName corresponds to the identification or the list title of a list on the site and there is no XML document with the same namespace URI exist] the protocol server MUST return a success UpdateContentTypesXmlDocumentResult.");

            #endregion
        }
S02_OperationOnContentType