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

MSLISTSWS_S02_TC02_ApplyContentTypeToList_InvalidListName() private method

        public void MSLISTSWS_S02_TC02_ApplyContentTypeToList_InvalidListName()
        {
            // Add a list.
            string listName = TestSuiteHelper.GetUniqueListName();
            string listId = TestSuiteHelper.CreateList(listName);
            this.Site.Assert.IsNotNull(listId, "Test suite should create the list successfully.");

            string invalidListName = TestSuiteHelper.GetInvalidGuidAndNocorrespondString();
            string errorCode = string.Empty;
            bool isExistentFault = false;

            #region test ApplyContentTypeToList

            // Call ApplyContentTypeToList method with valid list name.
            ApplyContentTypeToListResponseApplyContentTypeToListResult applyResult = this.listswsAdapter.ApplyContentTypeToList(null, AdapterHelper.SiteDocumentContentTypeId, listName);
            this.Site.Assert.IsNotNull(
                        applyResult.Success,
                        "Apply content type {0} to the list {1} should succeed.",
                        AdapterHelper.SiteDocumentContentTypeId,
                        listName);

            // Use a nonexistent list name
            try
            {
                this.listswsAdapter.ApplyContentTypeToList(null, AdapterHelper.SiteDocumentContentTypeId, invalidListName);
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsTrue(isExistentFault, "The server response should contain a SOAP fault while ApplyContentTypeToList operation when the list name is invalid.");

            // If a SOAP fault is returned, then capture R385.
            Site.CaptureRequirementIfIsTrue(
                isExistentFault,
                385,
                @"[In ApplyContentTypeToList operation] If the operation fails, a SOAP fault MUST be returned.");

            if (Common.IsRequirementEnabled(2752, this.Site))
            {
                // If the error code is "0x82000006", then capture R2752.
                Site.CaptureRequirementIfAreEqual<string>(
                    "0x82000006",
                    errorCode,
                    2752,
                    @"[In ApplyContentTypeToList operation]Implementation does return a SOAP fault with error code 0x82000006, if listName does not correspond to a list from either of these checks.(SharePoint Foundation 2010 and above follow this behavior.)");
            }
            #endregion test ApplyContentTypeToList
        }
S02_OperationOnContentType