Exemple #1
0
        /// <summary>
        /// Generate contentType properties.
        /// </summary>
        /// <returns>Generated content type properties</returns>
        protected UpdateContentTypeContentTypeProperties GenerateContentTypeProperties()
        {
            UpdateContentTypeContentTypeProperties contentTypeProps = new UpdateContentTypeContentTypeProperties();

            contentTypeProps.ContentType             = new ContentTypePropertyDefinition();
            contentTypeProps.ContentType.Description = this.GenerateRandomString(10);
            contentTypeProps.ContentType.Title       = this.contentTypeTypeTitle;
            return(contentTypeProps);
        }
 /// <summary>
 /// Generate contentType properties.
 /// </summary>
 /// <returns>Generated content type properties</returns>
 protected UpdateContentTypeContentTypeProperties GenerateContentTypeProperties()
 {
     UpdateContentTypeContentTypeProperties contentTypeProps = new UpdateContentTypeContentTypeProperties();
     contentTypeProps.ContentType = new ContentTypePropertyDefinition();
     contentTypeProps.ContentType.Description = this.GenerateRandomString(10);
     contentTypeProps.ContentType.Title = this.contentTypeTypeTitle;
     return contentTypeProps;
 }
        public void MSLISTSWS_S02_TC66_UpdateContentType_WithListTitle_Succeed()
        {
            #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 should succeed.");

            #endregion

            #region Create a content type

            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            string parentTypeID = TestSuiteHelper.GetContentTypeId(listId, TestSuiteHelper.GetFirstExistContentTypeName(listId));

            // Create a contentType property
            CreateContentTypeContentTypeProperties addProperties = new CreateContentTypeContentTypeProperties();
            addProperties.ContentType = new ContentTypePropertyDefinition();
            addProperties.ContentType.Description = displayName;
            addProperties.ContentType.Title = displayName;
            addProperties.ContentType.Group = displayName;

            string newContentTypeId = this.listswsAdapter.CreateContentType(
                                                    listName,
                                                    displayName,
                                                    parentTypeID,
                                                    null,
                                                    addProperties,
                                                    "TRUE");

            this.Site.Assert.IsNotNull(newContentTypeId, "Create list content type should succeed.");

            #endregion

            #region Invoke GetListContentTypes to get the old version

            GetListContentTypeResponseGetListContentTypeResult getListContentTypeResult = null;
            getListContentTypeResult = this.listswsAdapter.GetListContentType(listName, newContentTypeId);

            this.Site.Assert.IsNotNull(getListContentTypeResult, "GetListContentType operation should succeed.");

            #endregion

            #region Abstract Value Bind

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

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

            #endregion

            #region UpdateContentType

            UpdateContentTypeResponseUpdateContentTypeResult updateContentTypeResultUpdate
                = this.listswsAdapter.UpdateContentType(listName, newContentTypeId, properties, addFields, null, null, bool.TrueString);

            this.Site.Assert.IsNotNull(updateContentTypeResultUpdate, "UpdateContentType operation should succeed.");

            #endregion UpdateContentType

            // Verify R798.
            Site.CaptureRequirement(
                798,
                @"[In UpdateContentType operation] If the specified listName is not a valid GUID, check if the listName corresponds to the list title of a list on the site and, if so, use that list.");

            // Verify R799
            Site.CaptureRequirement(
                799,
                @"[In UpdateContentType operation] If the specified listName does not correspond to the identification of a list on the site, check if the listName corresponds to the list title of a list on the site and, if so, use that list.");

            // Verify R1999
            Site.CaptureRequirementIfAreEqual<string>(
                getListContentTypeResult.ContentType.Description,
                updateContentTypeResultUpdate.Results.ListProperties.Description,
                1999,
                @"[UpdateContentTypeResponse]ListProperties.Description: The description of the content type.");

            // Verify R2001
            Site.CaptureRequirementIfAreEqual<string>(
                getListContentTypeResult.ContentType.Group,
                updateContentTypeResultUpdate.Results.ListProperties.Group,
                2001,
                @"[UpdateContentTypeResponse]ListProperties.Group: The name of the content type group in which this content type is contained.");

            // Verify R2003
            Site.CaptureRequirementIfAreEqual<string>(
                getListContentTypeResult.ContentType.ID,
                updateContentTypeResultUpdate.Results.ListProperties.ID,
                2003,
                @"[UpdateContentTypeResponse]ListProperties.ID: The content type identifier for this content type.");

            // Verify R2004
            Site.CaptureRequirementIfAreEqual<string>(
                getListContentTypeResult.ContentType.Name,
                updateContentTypeResultUpdate.Results.ListProperties.Name,
                2004,
                @"[UpdateContentTypeResponse]ListProperties.Name: The name of the content type.");
        }
        public void MSLISTSWS_S02_TC65_UpdateContentType_WithGuid_Succeed()
        {
            #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 should succeed.");

            #endregion Add a list

            #region Invoke GetListContentTypes to get the old version

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

            this.Site.Assert.IsNotNull(result, "Calling GetListContentTypes successfully.");
            #endregion

            #region Abstract Value Bind
            UpdateContentTypeContentTypeProperties properties = new UpdateContentTypeContentTypeProperties();
            properties.ContentType = new ContentTypePropertyDefinition();

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

            addFields.Fields[0].Field.Node = "//" + listId + "/" + result.ContentTypes.ContentType[0].ID + "/" + addFields.Fields[0].ID;
            #endregion

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

            if (updateContentTypeResultUpdate == null)
            {
                Site.Assert.Fail("Update contentType operation failed as Updatecontent type result returned null.");
            }

            if (Common.IsRequirementEnabled(7921, this.Site))
            {
                // Verify MS-LISTSWS requirement: MS-LISTSWS_R7921.
                // If updating content type is successful, it means implementation does support this UpdateContentType method. R7921 can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    updateContentTypeResultUpdate,
                    7921,
                    @"Implementation does support this method[UpdateContentType]. (Windows SharePoint Services 3.0 and above follow this behavior.)");
            }

            // Verify R797.
            Site.CaptureRequirement(
                797,
                @"[In UpdateContentType operation] If the specified listName is a valid GUID and corresponds to the identification of a list on the site, use that list.");

            // Verify R828.
            Site.CaptureRequirement(
                828,
                @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In UpdateContentTypeResult element] If no error conditions, as specified previously, cause the protocol server to return a SOAP fault, an UpdateContentTypeResult MUST be returned.");

            #endregion

            #region GetListContentType

            GetListContentTypeResponseGetListContentTypeResult getListContentType = this.listswsAdapter.GetListContentType(listId, result.ContentTypes.ContentType[0].ID);

            // Verify whether the ContentTypeFields had been updated.
            bool appropriateIsUpdate = false;

            for (int i = 0; i < getListContentType.ContentType.Fields.Items.Length; i++)
            {
                FieldDefinitionCTRemove fieldRefDefCT = (FieldDefinitionCTRemove)getListContentType.ContentType.Fields.Items[i];

                if (fieldRefDefCT.DisplayName.Equals(Common.GetConfigurationPropertyValue("ListFieldText", this.Site)))
                {
                    appropriateIsUpdate = true;
                    break;
                }
            }

            Site.CaptureRequirementIfIsTrue(
                appropriateIsUpdate,
                2274,
                @"[In UpdateContentType operation] The protocol server updates the appropriate fields on the content type.");

            Site.CaptureRequirementIfIsTrue(
                appropriateIsUpdate,
                2275,
                @"[In UpdateContentType operation] The protocol server updates the content type with the given properties.");

            #endregion
        }
        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.");
        }
        public void MSLISTSWS_S02_TC63_UpdateContentType_UpdateFieldsError()
        {
            #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_TC62_UpdateContentType_UpdateFieldsError, 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 fieldNameB = TestSuiteHelper.GetUniqueFieldName();
            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 two update fields, one valid and the other one is invalid
            AddOrUpdateFieldsDefinition updateFields = TestSuiteHelper.CreateUpdateContentTypeFields(fieldNameA, fieldNameB);

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

            UpdateContentTypeContentTypeProperties updateProperties = new UpdateContentTypeContentTypeProperties();

            // Call UpdateContentType operation to update the content type.
            UpdateContentTypeResponseUpdateContentTypeResult updateResult = this.listswsAdapter.UpdateContentType(
                                                    listName,
                                                    contentTypeId,
                                                    updateProperties,
                                                    addFields,
                                                    updateFields,
                                                    deleteFields,
                                                    Convert.ToString(true));

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

            bool isCaptured = updateResult.Results.Method[2].ErrorCode == "0x82000007";

            // Capture R811 if the error code is "0x82000007".
            Site.CaptureRequirementIfIsTrue(
                isCaptured,
                811,
                @"[In UpdateContentType operation] [The protocol server updates the appropriate fields on the content type.] If the fields to be updated do not exist in the specified contentType or they do not exist in the specified list, the protocol server MUST return a Response with error code 0x82000007. ");

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

            Site.Assert.IsNotNull(getResult, "The result of GetListContentType operation should not be NULL");
        }
 /// <remarks/>
 public System.IAsyncResult BeginUpdateContentType(string listName, string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields, string addToView, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateContentType", new object[] {
             listName,
             contentTypeId,
             contentTypeProperties,
             newFields,
             updateFields,
             deleteFields,
             addToView}, callback, asyncState);
 }
        /// <summary>
        /// The UpdateContentType operation is used to update a content type on a list.
        /// </summary>
        /// <param name="listName">The name of the list of which a content type will be updated</param>
        /// <param name="contentTypeId">The identifier of the content type which will be updated</param>
        /// <param name="contentTypeProperties">The container for properties to set on the content type</param>
        /// <param name="newFields">The new fields that will be used as parameter in UpdateContentType</param>
        /// <param name="updateFields">The fields that will be updated</param>
        /// <param name="deleteFields">The fields that will be used as parameter in UpdateContentType</param>
        /// <param name="addToView">Specifies whether the fields will be added to the default list view, "TRUE" means add to the view and "False" means not.</param>
        /// <returns>Update content type Result</returns>
        public UpdateContentTypeResponseUpdateContentTypeResult UpdateContentType(string listName, string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields, string addToView)
        {
            this.Site.Assert.IsNotNull(this.listsProxy, "The Proxy instance should not be NULL. If assert failed, the adapter need to be initialized");

            UpdateContentTypeResponseUpdateContentTypeResult result = null;
            try
            {
                result = this.listsProxy.UpdateContentType(listName, contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields, addToView);

                // Verify the requirements of the transport.
                this.VerifyTransportRequirements();

                // Verify the requirements of UpdateContentType operation.
                this.VerifyUpdateContentTypeOperation(result);
            }
            catch (XmlSchemaValidationException exp)
            {
                // Log the errors and warnings
                this.LogSchemaValidationErrors();

                this.Site.Assert.Fail(exp.Message);
            }
            catch (SoapException)
            {
                this.VerifySoapExceptionFault();
                throw;
            }

            return result;
        }
        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
        }
        public void MSLISTSWS_S02_TC58_UpdateContentType_FieldExists()
        {
            #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_TC57_UpdateContentType_FieldExists, 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();

            // Create a content type.
            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 Operation when the update field name exists

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

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

            // Call UpdateContentType operation to update the content type.
            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 R830 if the error code is "0x00000000".
            Site.CaptureRequirementIfIsTrue(
                isCaptured,
                830,
                @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In ErrorCode element] For an update operation, if a reference to the field to be updated is found on the content type, the value MUST be ""0x00000000"".");

            // Construct an FieldDefinition, to verify the value of the Field.
            FieldDefinition dieldDef = result.Results.Method[0].Field;

            // Capture R833 if the Field is contains data.
            Site.CaptureRequirementIfIsNotNull(
                dieldDef,
                833,
                @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In Field element] If the ErrorCode is ""0x00000000"" for an update operation, Field MUST contain data for the Field.");

            #endregion
        }
        public void MSLISTSWS_S02_TC56_UpdateContentType_Combination()
        {
            string lisid = TestSuiteHelper.CreateList();

            // add a field into the list.
            string addedFieldName = TestSuiteHelper.GetUniqueFieldName();
            TestSuiteHelper.AddFieldsToList(lisid, new List<string> { addedFieldName }, new List<string> { "Counter" }, new List<string> { null });
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();

            // Create a content type
            string existringFieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            string contenttypeId = TestSuiteHelper.CreateContentType(lisid, displayName, new List<string> { existringFieldName });

            // Add a field into the content type
            AddOrUpdateFieldsDefinition addFields = TestSuiteHelper.CreateAddContentTypeFields(addedFieldName);
            UpdateContentTypeContentTypeProperties properties = new UpdateContentTypeContentTypeProperties();
            properties.ContentType = new ContentTypePropertyDefinition();
            UpdateContentTypeResponseUpdateContentTypeResult updateContentTypeResult = null;
            updateContentTypeResult = this.listswsAdapter.UpdateContentType(
                                            lisid,
                                            contenttypeId,
                                            properties,
                                            addFields,
                                            null,
                                            null,
                                            bool.TrueString);

            if (null == updateContentTypeResult || null == updateContentTypeResult.Results || null == updateContentTypeResult.Results.Method)
            {
                this.Site.Assert.Fail("Could not get the valid response from UpdateContentType operation");
            }

            bool isAddFieldsErrorCodeCorrect = "0x00000000".Equals(updateContentTypeResult.Results.Method[0].ErrorCode, StringComparison.OrdinalIgnoreCase);

            // Search the method items which are executed successfully
            var fieldRefsOfSuccessfulMethodItem = from methoditem in updateContentTypeResult.Results.Method
                                                  where "0x00000000".Equals(methoditem.ErrorCode, StringComparison.OrdinalIgnoreCase)
                                                        && methoditem.FieldRef != null
                                                  select methoditem.FieldRef;

            // Search the matched method item in  items which are executed successfully
            var fieldRefsOfMatchFieldName = from fieldItem in fieldRefsOfSuccessfulMethodItem
                                            where addedFieldName.Equals(fieldItem.Name, StringComparison.OrdinalIgnoreCase)
                                            select fieldItem;

            this.Site.CaptureRequirementIfAreEqual(
                1,
                fieldRefsOfMatchFieldName.Count(),
                832,
                @"[In UpdateContentType operation] [In UpdateContentTypeResponse element] [In FieldRef element] If the ErrorCode is ""0x00000000"" for an add operation, FieldRef MUST contain data for the reference to the field.");

            GetListContentTypeResponseGetListContentTypeResult getContentTypeResult = null;
            getContentTypeResult = this.listswsAdapter.GetListContentType(lisid, contenttypeId);

            if (null == getContentTypeResult || null == getContentTypeResult.ContentType || null == getContentTypeResult.ContentType.Fields
                || null == getContentTypeResult.ContentType.Fields.Items)
            {
                this.Site.Assert.Fail("Could not get the valid response from GetListContentType operation");
            }

            // Verify whether the field is successfully added into the content type.
            var matchedFielditems = from FieldDefinitionCTRemove fielditem in getContentTypeResult.ContentType.Fields.Items
                                    where addedFieldName.Equals(fielditem.Name, StringComparison.OrdinalIgnoreCase)
                                    select fielditem;

            this.Site.CaptureRequirementIfAreEqual(
                1,
                matchedFielditems.Count(),
                2273,
                @"[In UpdateContentType operation] The protocol server adds the appropriate fields to the content type.");

            // Delete an existing field on a contentType
            DeleteFieldsDefinition deleteFields = TestSuiteHelper.CreateDeleteContentTypeFields(addedFieldName);
            string fieldNameB = TestSuiteHelper.GetUniqueFieldName();
            DeleteFieldsDefinition deleteFieldserror = TestSuiteHelper.CreateDeleteContentTypeFields(fieldNameB);
            updateContentTypeResult = this.listswsAdapter.UpdateContentType(
                                             lisid,
                                             contenttypeId,
                                             properties,
                                             null,
                                             null,
                                             deleteFields,
                                             bool.TrueString);

            UpdateContentTypeResponseUpdateContentTypeResult updateResulterror = this.listswsAdapter.UpdateContentType(
                                                    lisid,
                                                    contenttypeId,
                                                    properties,
                                                    null,
                                                    null,
                                                    deleteFieldserror,
                                                    Convert.ToString(true));

            if (null == updateContentTypeResult || null == updateContentTypeResult.Results || null == updateContentTypeResult.Results.Method)
            {
                this.Site.Assert.Fail("Could not get the valid response from UpdateContentType operation");
            }

            bool isDeleteFieldsErrorCodeCorrect = "0x00000000".Equals(updateContentTypeResult.Results.Method[0].ErrorCode, StringComparison.OrdinalIgnoreCase);

            // Verify requirement #829
            this.Site.CaptureRequirementIfIsTrue(
                isAddFieldsErrorCodeCorrect && isDeleteFieldsErrorCodeCorrect,
                829,
                @"[In UpdateContentType operation] For an add or delete operation, if the field to be added or deleted is found on the list or context site, the value of ErrorCode MUST be ""0x00000000"".");

            // Verify whether the field is deleted successfully
            var executedSuccessfullyMethodItem = from methoditem in updateContentTypeResult.Results.Method
                                                 where "0x00000000".Equals(methoditem.ErrorCode, StringComparison.OrdinalIgnoreCase)
                                                 select methoditem.FieldRef;

            this.Site.Assert.AreEqual(
                                    1,
                                    executedSuccessfullyMethodItem.Count(),
                                    "The DeletedFields method was not executed successfully.");

            getContentTypeResult = null;
            getContentTypeResult = this.listswsAdapter.GetListContentType(lisid, contenttypeId);
            if (null == getContentTypeResult || null == getContentTypeResult.ContentType || null == getContentTypeResult.ContentType.Fields
               || null == getContentTypeResult.ContentType.Fields.Items)
            {
                this.Site.Assert.Fail("Could not get the valid response from GetListContentType operation");
            }

            // Verify whether the field is successfully added into the content type 
            var leftields = from FieldDefinitionCTRemove fielditem in getContentTypeResult.ContentType.Fields.Items
                            where addedFieldName.Equals(fielditem.Name, StringComparison.OrdinalIgnoreCase)
                            select fielditem;

            // If the deleted field does not exist in response of GetContenttype operation, R804 is captured.
            this.Site.CaptureRequirementIfAreEqual(
                                            0,
                                            leftields.Count(),
                                            804,
                                            @"[In UpdateContentType operation] If the specified content type is found, the protocol server deletes the appropriate fields from the content type.");
            // If the valid deleted field does not exist in response and invalid deleted field response an error code 0x82000007, R1977001 is captured.
            bool isCaptured = updateResulterror.Results.Method[0].ErrorCode == "0x82000007" && leftields.Count() ==0;
            Site.CaptureRequirementIfIsTrue(
               isCaptured,
               1977001,
               @"[In UpdateContentType operation] [If the fields to be deleted do not exist in the specified list, the protocol server MUST return a Response with error code 0x82000007. ] [This indicates that the fields specified in the deleteFields element do not exist in the specified list, ]and all fields that were deleted before the error was encountered MUST stay deleted.");
        }
        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
        }
        public void MSLISTSWS_S02_TC33_GetListContentTypesAndProperties_ContentTypeVersion()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2230, this.Site), @"Test is executed only when R2230Enabled is set to true.");

            #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 GetListContentTypesAndProperties to get the old version

            GetListContentTypesAndPropertiesResponseGetListContentTypesAndPropertiesResult result
                = this.listswsAdapter.GetListContentTypesAndProperties(listName, null, null, false, false);

            this.Site.Assert.IsNotNull(result, "Calling GetListContentTypesAndProperties successfully.");

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

            #endregion

            #region Invoke UpdateContentType

            #region Abstract Value Bind

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

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

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

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

            #endregion

            #region Invoke GetListContentTypesAndProperties to get the new version

            result = this.listswsAdapter.GetListContentTypesAndProperties(listName, null, null, false, false);

            this.Site.Assert.IsNotNull(result, "Calling GetListContentTypesAndProperties successfully.");
            int newVersion = result.ContentTypes.ContentType[0].Version;

            #endregion

            #region Verify R1066

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

            #endregion
        }
 /// <remarks/>
 public void UpdateContentTypeAsync(string listName, string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields, string addToView, object userState)
 {
     if ((this.UpdateContentTypeOperationCompleted == null))
     {
         this.UpdateContentTypeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateContentTypeOperationCompleted);
     }
     this.InvokeAsync("UpdateContentType", new object[] {
             listName,
             contentTypeId,
             contentTypeProperties,
             newFields,
             updateFields,
             deleteFields,
             addToView}, this.UpdateContentTypeOperationCompleted, userState);
 }
 /// <remarks/>
 public void UpdateContentTypeAsync(string listName, string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields, string addToView)
 {
     this.UpdateContentTypeAsync(listName, contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields, addToView, null);
 }
        /// <summary>
        /// This operation is used to update a content type on the context site.
        /// </summary>
        /// <param name="contentTypeId">contentTypeID is the ID of the content type to be updated.</param>
        /// <param name="contentTypeProperties">properties is the container for properties to set on the content type.</param>
        /// <param name="newFields">newFields is the container for a list of existing fields to be included in the content type.</param>
        /// <param name="updateFields">updateFields is the container for a list of fields to be updated on the content type.</param>
        /// <param name="deleteFields">deleteFields is the container for a list of fields to be updated on the content type.</param>
        /// <returns>The result of UpdateContentType.</returns>
        public UpdateContentTypeResponseUpdateContentTypeResult UpdateContentType(string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields)
        {
            UpdateContentTypeResponseUpdateContentTypeResult result = new UpdateContentTypeResponseUpdateContentTypeResult();

            result = this.service.UpdateContentType(contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields);

            this.ValidateUpdateContentType();
            this.CaptureTransportRelatedRequirements();

            return result;
        }
        public void MSLISTSWS_S02_TC60_UpdateContentType_IncorrectContentTypeId()
        {
            #region Add a list
            string listName = TestSuiteHelper.GetUniqueListName();

            string listId = TestSuiteHelper.CreateList(listName);

            bool isListCreatedSuccessful = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessful, "Creating list should succeed.");

            #endregion Add a list

            #region Invoke GetListContentTypes to get the old version

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

            this.Site.Assert.IsNotNull(result, "GetListContentTypes operation should succeed.");
            #endregion

            #region Abstract Value Bind
            UpdateContentTypeContentTypeProperties properties = new UpdateContentTypeContentTypeProperties();
            properties.ContentType = new ContentTypePropertyDefinition();

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

            #region UpdateContentType

            // incorrect contentTypeID
            string invalidContentTypeID = TestSuiteHelper.GetInvalidGuidAndNocorrespondString();
            try
            {
                this.listswsAdapter.UpdateContentType(listId, invalidContentTypeID, properties, addFields, null, null, bool.TrueString);
                Site.Assert.Fail("UpdateContentType should fail when the parent content type ID is invalid, but it passed.");
            }
            catch (SoapException ex)
            {
                Site.CaptureRequirementIfIsNotNull(
                    ex,
                    801,
                    @"[In UpdateContentType operation] If the contentTypeId is not a valid content type identifier, the protocol server MUST return a SOAP fault.");
            }

            // contentTypeId is not the content type identifier of a content type on the list
            invalidContentTypeID = Guid.NewGuid().ToString("N");

            try
            {
                this.listswsAdapter.UpdateContentType(listId, invalidContentTypeID, properties, addFields, null, null, bool.TrueString);
                Site.Assert.Fail("Calling UpdateContentType should fail");
            }
            catch (SoapException ex)
            {
                string errorCode = TestSuiteHelper.GetErrorCode(ex);

                Site.CaptureRequirementIfIsNotNull(
                    ex,
                    802,
                    @"[In UpdateContentType operation] If the contentTypeId is not the content type identifier of a content type on the list, the protocol server MUST return a SOAP fault.");

                Site.CaptureRequirementIfIsNull(
                    errorCode,
                    1976,
                    @"[In UpdateContentType operation] [If the contentTypeId is not the content type identifier of a content type on the list, the protocol server MUST return a SOAP fault.]There is no error code for this fault.");
            }
            #endregion UpdateContentType
        }
        public void MSLISTSWS_S02_TC61_UpdateContentType_IncorrectListName()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2766, this.Site), @"Test is executed only when R2766Enabled is set to true.");

            #region Add a list
            string listName = TestSuiteHelper.GetUniqueListName();

            string listId = TestSuiteHelper.CreateList(listName);

            bool isListCreatedSuccessful = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessful, "Creating list successfully.");

            #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 should succeed.");
            #endregion

            #region Abstract Value Bind

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

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

            #endregion

            #region UpdateContentType
            string invalidList = DateTime.Now.TimeOfDay.ToString();
            bool caughtSoapException = false;
            try
            {
                this.listswsAdapter.UpdateContentType(invalidList, result.ContentTypes.ContentType[0].ID, properties, addFields, null, null, bool.TrueString);
                Site.Assert.Fail("UpdateContentType should fail when the list name is neither the exist GUID nor title, but it passed.");
            }
            catch (SoapException exp)
            {
                caughtSoapException = true;

                Site.CaptureRequirementIfAreEqual<string>(
                    "0x82000006",
                    exp.Detail.LastChild.InnerText,
                    2766,
                    @"[In UpdateContentType 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.)");

                Site.CaptureRequirementIfAreEqual<string>(
                    "0x82000006",
                    exp.Detail.LastChild.InnerText,
                    1975,
                    @"[In UpdateContentType operation] [If the specified listName does not correspond to a list from either of these checks, a SOAP fault should<73> be returned with error code 0x82000006.] This indicates that the list does not exist or might have been deleted by another user.");
            }
            finally
            {
                Site.Assert.IsTrue(caughtSoapException, "A SOAP exception should be thrown by the server when invoke the operation 'UpdateContentType' with incorrect listName.");
            }

            #endregion UpdateContentType
        }
Exemple #19
0
        /// <summary>
        /// This operation is used to update a content type on the context site.
        /// </summary>
        /// <param name="contentTypeId">contentTypeID is the ID of the content type to be updated.</param>
        /// <param name="contentTypeProperties">properties is the container for properties to set on the content type.</param>
        /// <param name="newFields">newFields is the container for a list of existing fields to be included in the content type.</param>
        /// <param name="updateFields">updateFields is the container for a list of fields to be updated on the content type.</param>
        /// <param name="deleteFields">deleteFields is the container for a list of fields to be updated on the content type.</param>
        /// <returns>The result of UpdateContentType.</returns>
        public UpdateContentTypeResponseUpdateContentTypeResult UpdateContentType(string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields)
        {
            UpdateContentTypeResponseUpdateContentTypeResult result = new UpdateContentTypeResponseUpdateContentTypeResult();

            result = this.service.UpdateContentType(contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields);

            this.ValidateUpdateContentType();
            this.CaptureTransportRelatedRequirements();

            return(result);
        }
 public UpdateContentTypeResponseUpdateContentTypeResult UpdateContentType(string listName, string contentTypeId, UpdateContentTypeContentTypeProperties contentTypeProperties, AddOrUpdateFieldsDefinition newFields, AddOrUpdateFieldsDefinition updateFields, DeleteFieldsDefinition deleteFields, string addToView)
 {
     object[] results = this.Invoke("UpdateContentType", new object[] {
             listName,
             contentTypeId,
             contentTypeProperties,
             newFields,
             updateFields,
             deleteFields,
             addToView});
     return ((UpdateContentTypeResponseUpdateContentTypeResult)(results[0]));
 }