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

MSLISTSWS_S02_TC64_UpdateContentType_UpdatePropertiesError() private method

        public void MSLISTSWS_S02_TC64_UpdateContentType_UpdatePropertiesError()
        {
            #region Create a new list

            bool isCreateListSuccess = false;
            string listName = TestSuiteHelper.GetUniqueListName();
            string listGuid = TestSuiteHelper.CreateList(listName);
            isCreateListSuccess = !string.IsNullOrEmpty(listGuid);
            Site.Assert.IsTrue(isCreateListSuccess, "MSLISTSWS_S02_TC63_UpdateContentType_UpdatePropertiesError, create a new list successfully.");
            #endregion

            #region Create an content type on the list
            string contentTypeId = null;
            string fieldNameA = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            string fieldNameC = Common.GetConfigurationPropertyValue("ListFieldCounter", this.Site);
            string contentTypeDisplayName = TestSuiteHelper.GetUniqueContentTypeName();

            contentTypeId = TestSuiteHelper.CreateContentType(listName, contentTypeDisplayName, new List<string> { fieldNameA });
            Site.Assert.IsNotNull(contentTypeId, "Call CreateContentType operation to create a content type successfully.");
            #endregion

            // Call GetListContentType operation to get the content type.
            this.listswsAdapter.GetListContentType(
                                            listName,
                                            contentTypeId);

            // Construct one valid added field
            AddOrUpdateFieldsDefinition addFields = TestSuiteHelper.CreateAddContentTypeFields(fieldNameC);

            // Construct one valid updated field
            AddOrUpdateFieldsDefinition updateFields = TestSuiteHelper.CreateUpdateContentTypeFields(fieldNameA);

            // Construct one valid delete field
            DeleteFieldsDefinition deleteFields = TestSuiteHelper.CreateDeleteContentTypeFields(fieldNameA);

            // Construct invalid title property which contains white space
            UpdateContentTypeContentTypeProperties updateProperties = new UpdateContentTypeContentTypeProperties();
            updateProperties.ContentType = new ContentTypePropertyDefinition();

            bool isUpdateContentTypeFail = false;
            try
            {
                // Set an empty for the content type's title so that it would generate a SOAP fault
                updateProperties.ContentType.Title = string.Empty;

                // Call UpdateContentType operation to update the content type.
                this.listswsAdapter.UpdateContentType(
                                                         listName,
                                                         contentTypeId,
                                                         updateProperties,
                                                         addFields,
                                                         updateFields,
                                                         deleteFields,
                                                         Convert.ToString(true));
            }
            catch (SoapException)
            {
                isUpdateContentTypeFail = true;
            }

            // If the server return a soap fault, capture R816.
            Site.CaptureRequirementIfIsTrue(
                isUpdateContentTypeFail,
                816,
                @"[In UpdateContentType operation] [The protocol server updates the content type with the given properties.] If an error is encountered during this operation, the protocol server MUST return a SOAP fault.");
        }
S02_OperationOnContentType