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

MSLISTSWS_S02_TC39_GetListContentTypes_VersionTest() private method

        public void MSLISTSWS_S02_TC39_GetListContentTypes_VersionTest()
        {
            #region Add a list
            string listName = TestSuiteHelper.GetUniqueListName();

            string listId = TestSuiteHelper.CreateList(listName);

            bool isListCreatedSuccessful = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessful, "Create List succeeded.");

            #endregion Add a list

            #region Invoke GetListContentTypes to get the old version

            GetListContentTypesResponseGetListContentTypesResult result = this.listswsAdapter.GetListContentTypes(listName, null);

            this.Site.Assert.IsNotNull(result, "GetListContentTypes Succeeded.");

            int oldVersion = result.ContentTypes.ContentType[0].Version;

            #endregion

            #region Abstract Value Bind

            UpdateContentTypeContentTypeProperties properties = new UpdateContentTypeContentTypeProperties();
            properties.ContentType = new ContentTypePropertyDefinition();

            AddOrUpdateFieldsDefinition addFields = TestSuiteHelper.CreateAddContentTypeFields(Common.GetConfigurationPropertyValue("ListFieldText", this.Site));
            #endregion

            #region Invoke UpdateContentType
            UpdateContentTypeResponseUpdateContentTypeResult updateContentTypeResultUpdate
                = this.listswsAdapter.UpdateContentType(listName, result.ContentTypes.ContentType[0].ID, properties, addFields, null, null, bool.TrueString);

            this.Site.Assert.IsNotNull(updateContentTypeResultUpdate, "UpdateContentType successfully.");
            #endregion

            #region Invoke GetListContentTypes to get the new version

            result = this.listswsAdapter.GetListContentTypes(listName, string.Empty);

            this.Site.Assert.IsNotNull(result, "GetListContentTypes Succeeded.");

            int newVersion = result.ContentTypes.ContentType[0].Version;

            #endregion

            #region Verify 619

            if ((oldVersion != -1) && (newVersion != -1))
            {
                // When both the old version and the new version are obtained, the following requirement                
                // can be captured if the new version is equal to the old version plus 1.
                Site.CaptureRequirementIfAreEqual<int>(
                    oldVersion + 1,
                    newVersion,
                    619,
                    @"[GetListContentTypesResult.ContentTypes.ContentType.Version] The protocol server MUST increment the value by 1 each time the content type definition is edited.");
            }

            #endregion
        }
S02_OperationOnContentType