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

MSLISTSWS_S02_TC40_GetListContentTypes_BestMatch() private method

private MSLISTSWS_S02_TC40_GetListContentTypes_BestMatch ( ) : void
return void
        public void MSLISTSWS_S02_TC40_GetListContentTypes_BestMatch()
        {
            #region Add a list

            string listName = TestSuiteHelper.CreateList();

            bool isListCreatedSuccessful = !string.IsNullOrEmpty(listName);
            this.Site.Assert.IsTrue(isListCreatedSuccessful, "Create List succeeded.");
            #endregion Add a list
            GetListContentTypesResponseGetListContentTypesResult listContentTypes = this.listswsAdapter.GetListContentTypes(listName, null);

            this.Site.Assert.IsNotNull(listContentTypes, "GetListContentType succeeded.");
            string contentTypeId = null;
            for (int i = 0; i < listContentTypes.ContentTypes.ContentType.Length; i++)
            {
                if (listContentTypes.ContentTypes.ContentType[i].Name.Equals("Document"))
                {
                    contentTypeId = listContentTypes.ContentTypes.ContentType[i].ID;
                    break;
                }
            }

            // GetListContentTypes using the list's title and specifying Document content type is "best match".
            listContentTypes = this.listswsAdapter.GetListContentTypes(listName, contentTypeId);

            Site.Assert.IsNotNull(listContentTypes, @"[In GetListContentTypes operation] If the specified listName a list name, the protocol server MUST return a GetListResponse element.");

            // BestMatch is specified as TRUE at all, since it is TRUEONLY type.
            foreach (GetListContentTypesResponseGetListContentTypesResultContentTypesContentType ct in listContentTypes.ContentTypes.ContentType)
            {
                if (ct.Name == "Document")
                {
                    Site.Assert.IsTrue(ct.BestMatchSpecified, "The content type identified by the contentTypeId element in the GetListContentTypesSoapIn message should be specified as best match.");
                }
                else
                {
                    Site.Assert.IsFalse(ct.BestMatchSpecified, "The content type not identified by the contentTypeId element in the GetListContentTypesSoapIn message should not be specified as best match.");
                }
            }

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R1844
            // Since the asserts above are successful,MS-LISTSWS_R1844 can be captured directly.
            Site.CaptureRequirement(
                1844,
                @"[GetListContentTypesResult.ContentTypes.ContentType.BestMatch]If specified at all, then MUST be specified on the ContentType element that represents the ""best match"" to the content type identified by the contentTypeId element in the GetListContentTypesSoapIn message.");
        }
S02_OperationOnContentType