Microsoft.Protocols.TestSuites.MS_LISTSWS.TestSuiteHelper.GetFirstExistContentTypeName C# (CSharp) Method

GetFirstExistContentTypeName() public static method

A method used to get a existed Content Type, it is used in set a parent type value in CreateContentType operation.
public static GetFirstExistContentTypeName ( string listId ) : string
listId string A parameter represents the identification of a list
return string
        public static string GetFirstExistContentTypeName(string listId)
        {
            if (string.IsNullOrEmpty(listId))
            {
                testSite.Assert.Fail("The listId parameter should not be null or empty");
            }

            GetListContentTypesResponseGetListContentTypesResult result = null;
            try
            {
                result = listswsAdapter.GetListContentTypes(listId, null);
            }
            catch (SoapException soapEx)
            {                
                testSite.Debug.Fail(ErrorMessageTemplate, "getting list with list id " + listId, soapEx.Detail.InnerText);
            }

            string existedParentTypeName = string.Empty;
            if (result == null || result.ContentTypes == null || result.ContentTypes.ContentType == null
                || result.ContentTypes.ContentType.Length < 1)
            {
                string errorMsg = string.Format("The content type does not exist in current list [{0}]", listId);
                testSite.Assert.Fail(errorMsg);
            }

            existedParentTypeName = result.ContentTypes.ContentType[0].Name;
            return existedParentTypeName;
        }