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

MSLISTSWS_S02_TC59_UpdateContentType_FieldNotExists() private method

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

            bool isCreateListSuccess = false;
            string listName = TestSuiteHelper.GetUniqueListName();

            // Create a new list.
            string listGuid = TestSuiteHelper.CreateList(listName);
            isCreateListSuccess = !string.IsNullOrEmpty(listGuid);
            Site.Assert.IsTrue(isCreateListSuccess, "MSLISTSWS_S02_TC58_UpdateContentType_FieldNotExists, 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 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

            #region UpdateContentType when the update field name does not exist

            string fieldNameB = TestSuiteHelper.GetUniqueFieldName();
            UpdateContentTypeContentTypeProperties updateProperties = new UpdateContentTypeContentTypeProperties();
            updateProperties.ContentType = new ContentTypePropertyDefinition();

            AddOrUpdateFieldsDefinition updateField = TestSuiteHelper.CreateUpdateContentTypeFields(fieldNameB);
            UpdateContentTypeResponseUpdateContentTypeResult result = null;

            // Update created content type in the previous step without exist field name
            result = this.listswsAdapter.UpdateContentType(
                                            listName,
                                            contentTypeId,
                                            updateProperties,
                                            null,
                                            updateField,
                                            null,
                                            Convert.ToString(true));

            Site.Assert.IsNotNull(result, "The result of UpdateContentType operation should not be NULL");

            bool isCaptured = result.Results.Method[0].ErrorCode != "0x00000000";

            // Capture R831 if the error code is not "0x00000000".
            Site.CaptureRequirementIfIsTrue(
            isCaptured,
            831,
            @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In ErrorCode element] Otherwise [in any scenarios except the successful scenarios], the value of ErrorCode MUST be nonzero.");

            // Capture R834 if the error text is not null.
            Site.CaptureRequirementIfIsNotNull(
                result.Results.Method[0].ErrorText,
                834,
                @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In ErrorText element] If the ErrorCode is nonzero, ErrorText MUST contain an error string.");

            #endregion
        }
S02_OperationOnContentType