public void MSWEBSS_S01_TC01_CreateContentType()
        {
            // Create a new content type on the context site.
            ContentTypeType.ContentType = new ContentTypePropertyDefinition();
            ContentTypeType.ContentType.Description = this.ContentTypeDescription;
            ContentTypeType.ContentType.Title = this.ContentTypeTypeTitle;
            AddOrUpdateFieldsDefinition fields = GenerateNewFields();
            string contentTypeId = Adapter.CreateContentType(DisplayName, Common.GetConfigurationPropertyValue("CreateContentType_ValidateContentType", this.Site), fields, ContentTypeType);

            // Verify MS-WEBSS requirement: MS-WEBSS_R712, MS-WEBSS_R1023
            // Captured by Schema.
            Site.CaptureRequirementIfIsNotNull(
                contentTypeId,
                712,
                @"[In CreateContentTypeResponse] CreateContentTypeResult: If no error conditions as specified in the preceding section cause the protocol server to return a SOAP exception, a CreateContentTypeResult MUST be returned containing the content type identifier of the content type created.");

            if (Common.IsRequirementEnabled(1023, this.Site))
            {
                if (contentTypeId != null)
                {
                    // Verify MS-WEBSS requirement: MS-WEBSS_R1023
                    // When the system under test product name is Windows SharePoint Services 3.0 and above, if the server returns a
                    //  positive information when invoke CreateContentType operation, then the requirement can be captured.
                    Site.CaptureRequirement(
                        1023,
                        @"[In Appendix B: Product Behavior] Implementation does support this[CreateContentType] operation. (<7> Windows SharePoint Services 3.0 and above follow this behavior.)");
                }
            }

            // Create a new content type, set newFields to null.
            CreateContentTypeContentTypeProperties contentTypeProperties = new CreateContentTypeContentTypeProperties();
            contentTypeProperties.ContentType = new ContentTypePropertyDefinition();
            contentTypeProperties.ContentType.Description = this.GenerateRandomString(10);
            contentTypeProperties.ContentType.Title = this.GenerateRandomString(10);
            Adapter.CreateContentType(this.GenerateRandomString(10), Common.GetConfigurationPropertyValue("CreateContentType_ValidateContentType", this.Site), null, contentTypeProperties); 
        }
Exemplo n.º 2
0
        /// <summary>
        /// This operation is used to create a new content type on the context site
        /// </summary>
        /// <param name="displayName">displayName means the XML encoded name of content type to be created.</param>
        /// <param name="parentType">parentType is used to indicate the ID of a content type from which the content type to be created will inherit.</param>
        /// <param name="newFields">newFields is the container for a list of existing fields to be included in the content type.</param>
        /// <param name="contentTypeProperties">contentTypeProperties is the container for properties to set on the content type.</param>
        /// <returns>The ID of Created ContentType.</returns>
        public string CreateContentType(string displayName, string parentType, AddOrUpdateFieldsDefinition newFields, CreateContentTypeContentTypeProperties contentTypeProperties)
        {
            string contentTypeId = this.service.CreateContentType(displayName, parentType, newFields, contentTypeProperties);

            this.ValidateCreateContentType();
            this.CaptureTransportRelatedRequirements();

            return(contentTypeId);
        }
        /// <summary>
        /// The CreateContentType operation is used to create a new content type on a list.
        /// </summary>
        /// <param name="listName">The name of the list for which the content type will be created</param>
        /// <param name="displayName">The XML-encoded name of the content type to be created</param>
        /// <param name="parentType">The identification of a content type from which the content type to be created will inherit</param>
        /// <param name="fields">The container for a list of existing fields to be included in the content type </param>
        /// <param name="contentTypeProperties">The container for properties to set on the content type </param>
        /// <param name="addToView">Specifies whether the fields will be added to the default list view, where "TRUE" MUST correspond to true, and all other values to false</param>
        /// <returns>Return the ID of newly created content type.</returns>
        public string CreateContentType(string listName, string displayName, string parentType, AddOrUpdateFieldsDefinition fields, CreateContentTypeContentTypeProperties contentTypeProperties, string addToView)
        {
            this.Site.Assert.IsNotNull(this.listsProxy, "The Proxy instance should not be NULL. If assert failed, the adapter need to be initialized");
           
            string result = null;
            try
            {
                result = this.listsProxy.CreateContentType(listName, displayName, parentType, fields, contentTypeProperties, addToView);

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

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

            return result;
        }
        /// <summary>
        /// This method is used to Create a content type using the specified information.
        /// </summary>
        /// <param name="list">The list title or list id which the content type is created on.</param>
        /// <param name="displayName">The content type display name.</param>
        /// <param name="title">The content type title.</param>
        /// <param name="description">The content type description</param>
        /// <param name="parentTypeId">Specify the content type's parent content type ID.</param>
        /// <param name="addField">Specify the exist fields that adds into the list content type.</param>
        /// <returns>Return the content type id if successful, otherwise will fail the test case and log the reason</returns>
        private static string CreateContentType(string list, string displayName, string title, string description, string parentTypeId, AddOrUpdateFieldsDefinition addField)
        {
            CreateContentTypeContentTypeProperties addProperties = new CreateContentTypeContentTypeProperties();
            addProperties.ContentType = new ContentTypePropertyDefinition();
            addProperties.ContentType.Description = description;
            addProperties.ContentType.Title = title;

            string contentTypeId = null;

            try
            {
                contentTypeId = listswsAdapter.CreateContentType(
                                                    list,
                                                    displayName,
                                                    parentTypeId,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {              
                testSite.Assert.Fail(ErrorMessageTemplate, "creating content type in the list " + list, exp.Detail.InnerText);
                throw;
            }

            return contentTypeId;
        }
        /// <summary>
        /// This operation is used to create a new content type on the context site
        /// </summary>
        /// <param name="displayName">displayName means the XML encoded name of content type to be created.</param>
        /// <param name="parentType">parentType is used to indicate the ID of a content type from which the content type to be created will inherit.</param>
        /// <param name="newFields">newFields is the container for a list of existing fields to be included in the content type.</param>
        /// <param name="contentTypeProperties">contentTypeProperties is the container for properties to set on the content type.</param>
        /// <returns>The ID of Created ContentType.</returns>
        public string CreateContentType(string displayName, string parentType, AddOrUpdateFieldsDefinition newFields, CreateContentTypeContentTypeProperties contentTypeProperties)
        {
            string contentTypeId = this.service.CreateContentType(displayName, parentType, newFields, contentTypeProperties);

            this.ValidateCreateContentType();
            this.CaptureTransportRelatedRequirements();

            return contentTypeId;
        }
        public void MSLISTSWS_S02_TC12_CreateContentType_InvalidParentType()
        {
            #region Add a list

            // Add a new list to the server.
            string listId = TestSuiteHelper.CreateList();
            bool isListCreatedSuccessfully = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessfully, "Test suite should create the list successfully.");

            #endregion Add a list

            #region CreateContentType

            string errorCode = string.Empty;
            bool isExistentFault = false;
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            List<string> fieldNames = new List<string>();
            string fieldsName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            fieldNames.Add(fieldsName);

            // Invalid parentTypeID
            string parentTypeID = TestSuiteHelper.GetInvalidGuidAndNocorrespondString();
            AddOrUpdateFieldsDefinition addField = TestSuiteHelper.CreateAddContentTypeFields(fieldNames.ToArray());

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

            try
            {
                this.listswsAdapter.CreateContentType(
                                                    listId,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsTrue(isExistentFault, "The server response should contain a SOAP fault while requesting CreateContentType operation when the parent content type is not valid.");

            // If SOAP fault is returned, then capture R426 and R427.
            Site.CaptureRequirementIfIsTrue(
                isExistentFault,
                426,
                @"[In CreateContentType operation] If the parentType is not a valid content type identifier, the protocol server MUST return a SOAP fault.");

            Site.CaptureRequirementIfIsTrue(
                isExistentFault,
                427,
                @"[In CreateContentType operation] If the parentType is not the content type identifier of a content type available on the list, the protocol server MUST return a SOAP fault.");

            // If no error codes is returned, then capture R1683.
            Site.CaptureRequirementIfIsNull(
                errorCode,
                1683,
                @"[In CreateContentType operation] [If the parentType is not a valid content type identifier, the protocol server MUST return a SOAP fault.]There is no error code for this fault.");

            #endregion test CreateContentType
        }
        public void MSLISTSWS_S02_TC13_CreateContentType_UseListGuid_Succeed()
        {
            #region Add a list

            // Add a list to the server.
            string listId = TestSuiteHelper.CreateList();
            bool isListCreatedSuccessfully = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessfully, "Test suite should create the list successfully.");

            #endregion Add a list

            #region CreateContentType

            // Create a contentType with the listName which is a valid GUID.
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            List<string> fieldNames = new List<string>();
            string fieldsName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            fieldNames.Add(fieldsName);
            string parentTypeID = TestSuiteHelper.GetContentTypeId(listId, TestSuiteHelper.GetFirstExistContentTypeName(listId));
            AddOrUpdateFieldsDefinition addField = TestSuiteHelper.CreateAddContentTypeFields(fieldNames.ToArray());

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

            bool createContentTypeSucceeded = false;
            string contentType = this.listswsAdapter.CreateContentType(
                                                    listId,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            createContentTypeSucceeded = !string.IsNullOrEmpty(contentType);

            // Verify requirement R16801.
            // If there are no other errors, it means implementation does support this CreateContentType method. R16801 can be captured.
            if (Common.IsRequirementEnabled(16801, this.Site))
            {
                Site.CaptureRequirementIfIsTrue(
                    createContentTypeSucceeded,
                    16801,
                    @"Implementation does support this method[CreateContentType]. (Windows SharePoint Services 3.0 and above follow this behavior.)");
            }

            // If the CreateContentType is successful, then capture R421.
            Site.CaptureRequirementIfIsTrue(
                createContentTypeSucceeded,
                421,
                @"[In CreateContentType operation] If the specified listName is a valid GUID and corresponds to the identification of a list on the site, use that list.");

            #endregion test CreateContentType
        }
        public void MSLISTSWS_S02_TC09_CreateContentType_IncorrectDisplayName()
        {
            #region Add a list
            // Add a new list to the server.
            string listId = TestSuiteHelper.CreateList();
            bool isListCreatedSuccessfully = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessfully, "Test suite should create the list successfully.");

            #endregion Add a list

            #region CreateContentType

            string errorCode = string.Empty;
            bool isExistentFault = false;

            // Use a display name longer than 128 characters
            string displayName = "ContentTypeDisplayName" + TestSuiteHelper.GenerateRandomString(128);
            List<string> fieldNames = new List<string>();
            string fieldsName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            fieldNames.Add(fieldsName);
            string parentTypeID = TestSuiteHelper.GetContentTypeId(listId, TestSuiteHelper.GetFirstExistContentTypeName(listId));
            AddOrUpdateFieldsDefinition addField = TestSuiteHelper.CreateAddContentTypeFields(fieldNames.ToArray());

            // Create a contentType property
            CreateContentTypeContentTypeProperties addProperties = new CreateContentTypeContentTypeProperties();
            addProperties.ContentType = new ContentTypePropertyDefinition();
            addProperties.ContentType.Description = "CreateContentTypeDescriptionOf" + TestSuiteHelper.GenerateRandomString(5);
            addProperties.ContentType.Title = "CreateContentTitle" + TestSuiteHelper.GenerateRandomString(5);

            try
            {
                this.listswsAdapter.CreateContentType(
                                                    listId,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsTrue(isExistentFault, "SOAP fault should be returned for CreateContentType operation when the displayName is longer than 128 characters.");

            // If the returned error code is "0x80131600", then capture R436.
            Site.CaptureRequirementIfAreEqual<string>(
                "0x80131600",
                errorCode,
                436,
                @"[In CreateContentType operation] [In CreateContentType element] [In displayName field] [A SOAP fault with error code 0x80131600 MUST be returned if] It [displayName] is longer than 128 characters.");

            isExistentFault = false;
            errorCode = string.Empty;

            // Use a display name ending with period
            displayName = "CreateContentTypeDisplayName" + TestSuiteHelper.GenerateRandomString(5) + ".";

            try
            {
                this.listswsAdapter.CreateContentType(
                                                    listId,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsTrue(isExistentFault, "SOAP fault should be returned for CreateContentType operation when the displayName ends with a period.");
            Site.CaptureRequirementIfAreEqual<string>(
                "0x80131600",
                errorCode,
                437,
                @"[In CreateContentType operation] [In CreateContentType element] [In displayName field] [A SOAP fault with error code 0x80131600 MUST be returned if] It [displayName] ends with a period.");

            isExistentFault = false;
            errorCode = string.Empty;

            // Use a display name ending with whitespace
            displayName = "ContentTypeDisplayName" + TestSuiteHelper.GenerateRandomString(5) + " ";

            try
            {
                this.listswsAdapter.CreateContentType(
                                                    listId,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsTrue(isExistentFault, "The server response should contain a SOAP fault while requesting CreateContentType operation with whitespace at the end in DisplayName.");
            Site.CaptureRequirementIfAreEqual<string>(
                "0x80131600",
                errorCode,
                4837,
                @"[In CreateContentType operation] [In CreateContentType element] [In displayName field] [A SOAP fault with error code 0x80131600 MUST be returned if] It [displayName] begins or ends with whitespace.");

            isExistentFault = false;
            errorCode = string.Empty;

            // Verify R440 and R428
            const string ValidDisplayName = "ValidDisplayName";
            displayName = string.Format("{0}", ValidDisplayName);
            string contentTypeId = string.Empty;

            try
            {
                contentTypeId = this.listswsAdapter.CreateContentType(
                                                                listId,
                                                                displayName,
                                                                parentTypeID,
                                                                addField,
                                                                addProperties,
                                                                "TRUE");
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsFalse(isExistentFault, "The CreateContentType operation with valid display name '{0}' should be successful.", displayName);

            isExistentFault = false;
            errorCode = string.Empty;

            try
            {
                this.listswsAdapter.DeleteContentType(listId, contentTypeId);
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                isExistentFault = true;
            }

            this.Site.Assert.IsFalse(isExistentFault, "The DeleteContentType operation with content type Id '{0}' should be successful.", contentTypeId);

            isExistentFault = false;
            errorCode = string.Empty;

            // A container which contains all the invalid chars.
            string[] invalidLetterList = new string[] { "\t", "..", "*", "?", "\"", "#", "%", "<", ">", "{", "}", "|", "~", "&" };

            foreach (string invalidLetter in invalidLetterList)
            {
                // Use a display name containing invalid characters
                // The invalid display name format is: the valid display name appends an invalid letter.
                displayName = string.Format(
                                        "{0}{1}",
                                        ValidDisplayName,
                                        invalidLetter);

                try
                {
                    this.listswsAdapter.CreateContentType(
                                                        listId,
                                                        displayName,
                                                        parentTypeID,
                                                        addField,
                                                        addProperties,
                                                        "TRUE");
                }
                catch (SoapException exp)
                {
                    errorCode = TestSuiteHelper.GetErrorCode(exp);
                    isExistentFault = true;
                }

                this.Site.Assert.IsTrue(isExistentFault, "The server response should contain a SOAP fault while requesting CreateContentType operation when the displayName is {0}", displayName);

                this.Site.Assert.AreEqual<string>(
                    "0x80131600",
                    errorCode,
                    "SOAP fault code should be 0x80131600 for CreateContentType operation when the displayName is {0}",
                    displayName);
            }

            // If CreateContentType operation is successful for valid display name and 
            // returns SoapFault and error code 0x80131600 for all the invalid display names,
            // then capture the requirement R440.
            Site.CaptureRequirement(
                440,
                @"[In CreateContentType operation] [In CreateContentType element] [In displayName field] [A SOAP fault with error code 0x80131600 MUST be returned if] It [displayName] contains a tab, two consecutive periods, or any of the following characters: \/: * ? "" # % < > { } | ~ &.");

            // If CreateContentType operation is successful for valid display name and 
            // returns SoapFault and error code 0x80131600 for all the invalid display names,
            // then capture the requirement R428.
            Site.CaptureRequirement(
                428,
                @"[In CreateContentType operation] The protocol server attempts to create a new content type on the list with the given parent content type and display name. If an error specified in section 3.1.4.9.2.1 is encountered during this operation, the protocol server MUST return a SOAP fault.");

            #endregion test CreateContentType
        }
        public void MSLISTSWS_S02_TC10_CreateContentType_InvalidListName()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2753, this.Site), @"Test is executed only when R2753Enabled is set to true.");

            // Create a new listName
            string listName = TestSuiteHelper.GetUniqueListName();

            #region CreateContentType

            // Create a contentType with invalid listName.
            string errorCode = string.Empty;
            bool isExistentFault = false;
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            List<string> fieldNames = new List<string>();
            string fieldsName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            fieldNames.Add(fieldsName);

            AddOrUpdateFieldsDefinition addField = TestSuiteHelper.CreateAddContentTypeFields(fieldNames.ToArray());

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

            try
            {
                this.listswsAdapter.CreateContentType(
                                                    listName,
                                                    displayName,
                                                    null,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            }
            catch (SoapException exp)
            {
                isExistentFault = true;
                errorCode = TestSuiteHelper.GetErrorCode(exp);
            }

            this.Site.Assert.IsTrue(isExistentFault, "The server response should contain a SOAP fault while requesting CreateContentType operation.");

            Site.CaptureRequirementIfAreEqual<string>(
                "0x82000006",
                errorCode,
                2753,
                @"[In CreateContentType 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 CreateContentType
        }
        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_TC08_CreateContentType_ErrorPropertyName()
        {
            #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, "Creating a new list '{0}' should succeed.", listName);
            #endregion

            #region CreateContentType with error property name
            string fieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            AddOrUpdateFieldsDefinition addFields = TestSuiteHelper.CreateAddContentTypeFields(fieldName);
            string parentTypeName = TestSuiteHelper.GetFirstExistContentTypeName(listGuid);
            string parentTypeId = TestSuiteHelper.GetContentTypeId(listGuid, parentTypeName);
            string contentTypeDisplayName = TestSuiteHelper.GetUniqueContentTypeName();

            // Create a property naming issue by setting Title to a name ending with a period.
            CreateContentTypeContentTypeProperties addProperties = new CreateContentTypeContentTypeProperties();
            addProperties.ContentType = new ContentTypePropertyDefinition();
            addProperties.ContentType.Title = TestSuiteHelper.GetUniqueContentTypeName() + ".";
            bool soapFaultReturned = false;
            try
            {
                // Call CreateContentType operation to create a content type with invalid property name.
                this.listswsAdapter.CreateContentType(
                                                listGuid,
                                                contentTypeDisplayName,
                                                parentTypeId,
                                                addFields,
                                                addProperties,
                                                "TRUE");
            }
            catch (SoapException)
            {
                soapFaultReturned = true;
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R430. SOAP fault is{0} returned after invoking CreateContentType operation with invalid property name.", soapFaultReturned ? string.Empty : " not");
            Site.CaptureRequirementIfIsTrue(
                soapFaultReturned,
                430,
                @"The protocol server updates the content type with the given properties. If an error regarding the naming of properties, similar to the error specified in section 3.1.4.9.2.1 is encountered during this operation, the protocol server MUST return a SOAP fault.");
            #endregion

            #region Get the created content type and capture requirements.
            // Get the content type created in previous step.
            GetListContentTypesResponseGetListContentTypesResult contentTypesResult = null;
            contentTypesResult = this.listswsAdapter.GetListContentTypes(listName, null);

            GetListContentTypesResponseGetListContentTypesResultContentTypesContentType createdContentType = null;
            foreach (GetListContentTypesResponseGetListContentTypesResultContentTypesContentType contentType in contentTypesResult.ContentTypes.ContentType)
            {
                if (contentType.Name == contentTypeDisplayName)
                {
                    createdContentType = contentType;
                    break;
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R2268.");

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R2268
            // If the content type with the specified display name does exist, R2268 can be captured.
            Site.CaptureRequirementIfIsNotNull(
                createdContentType,
                2268,
                @"The protocol server updates the content type with the given properties. If an error regarding the naming of properties, similar to the error specified in section 3.1.4.9.2.1 is encountered during this operation, [the protocol server MUST return a SOAP fault, and] the content type will still exist as a newly created content type on the protocol server.");

            // Get fields in the content type.
            Site.Assert.IsNotNull(createdContentType.ID, "Newly created content type '{0}' should contain identifier in GetListContentTypes response.", contentTypeDisplayName);
            GetListContentTypeResponseGetListContentTypeResult contentTypeResult = null;
            contentTypeResult = this.listswsAdapter.GetListContentType(listName, createdContentType.ID);

            bool fieldExists = false;
            foreach (FieldDefinitionCTRemove field in contentTypeResult.ContentType.Fields.Items)
            {
                if (field.Name == fieldName)
                {
                    fieldExists = true;
                    break;
                }
            }

            // If the field exists in the created content type, then capture R2269.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R2269. Field '{0}' is{1} added in content type '{2}'.", fieldName, fieldExists ? string.Empty : " not", contentTypeDisplayName);
            Site.CaptureRequirementIfIsTrue(
                fieldExists,
                2269,
                @"The protocol server updates the content type with the given properties. If an error regarding the naming of properties, similar to the error specified in section 3.1.4.9.2.1 is encountered during this operation, [the protocol server MUST return a SOAP fault, and the content type will still exist as a newly created content type on the protocol server.] All fields that were added MUST stay added to the content type.");
            #endregion
        }
        public void MSLISTSWS_S02_TC14_CreateContentType_UseListTitle_Succeed()
        {
            #region Add a list

            // Get a listName which is an invalid GUID.
            string listName = TestSuiteHelper.GetInvalidGuidAndNocorrespondString();

            // Add a new list to the server.
            string listId = TestSuiteHelper.CreateList(listName);
            bool isListCreatedSuccessfully = !string.IsNullOrEmpty(listId);
            this.Site.Assert.IsTrue(isListCreatedSuccessfully, "Test suite should create the list successfully.");

            #endregion Add a list

            #region CreateContentType

            // Create a contentType with a listName which is an invalid GUID.
            string displayName = TestSuiteHelper.GetUniqueContentTypeName();
            List<string> fieldNames = new List<string>();
            string fieldsName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
            fieldNames.Add(fieldsName);
            string parentTypeID = TestSuiteHelper.GetContentTypeId(listId, TestSuiteHelper.GetFirstExistContentTypeName(listId));
            AddOrUpdateFieldsDefinition addField = TestSuiteHelper.CreateAddContentTypeFields(fieldNames.ToArray());

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

            bool createContentTypeSucceeded = false;
            string contentType = this.listswsAdapter.CreateContentType(
                                                    listName,
                                                    displayName,
                                                    parentTypeID,
                                                    addField,
                                                    addProperties,
                                                    "TRUE");
            createContentTypeSucceeded = !string.IsNullOrEmpty(contentType);

            // If the CreateContentType is successful, then capture R422.
            Site.CaptureRequirementIfIsTrue(
                createContentTypeSucceeded,
                422,
                @"[In CreateContentType 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.");

            #endregion test CreateContentType
        }
Exemplo n.º 13
0
 /// <remarks/>
 public void CreateContentTypeAsync(string listName, string displayName, string parentType, AddOrUpdateFieldsDefinition fields, CreateContentTypeContentTypeProperties contentTypeProperties, string addToView, object userState)
 {
     if ((this.CreateContentTypeOperationCompleted == null))
     {
         this.CreateContentTypeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateContentTypeOperationCompleted);
     }
     this.InvokeAsync("CreateContentType", new object[] {
             listName,
             displayName,
             parentType,
             fields,
             contentTypeProperties,
             addToView}, this.CreateContentTypeOperationCompleted, userState);
 }
Exemplo n.º 14
0
 /// <remarks/>
 public void CreateContentTypeAsync(string listName, string displayName, string parentType, AddOrUpdateFieldsDefinition fields, CreateContentTypeContentTypeProperties contentTypeProperties, string addToView)
 {
     this.CreateContentTypeAsync(listName, displayName, parentType, fields, contentTypeProperties, addToView, null);
 }
Exemplo n.º 15
0
 /// <remarks/>
 public System.IAsyncResult BeginCreateContentType(string listName, string displayName, string parentType, AddOrUpdateFieldsDefinition fields, CreateContentTypeContentTypeProperties contentTypeProperties, string addToView, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("CreateContentType", new object[] {
             listName,
             displayName,
             parentType,
             fields,
             contentTypeProperties,
             addToView}, callback, asyncState);
 }
Exemplo n.º 16
0
 public string CreateContentType(string listName, string displayName, string parentType, AddOrUpdateFieldsDefinition fields, CreateContentTypeContentTypeProperties contentTypeProperties, string addToView)
 {
     object[] results = this.Invoke("CreateContentType", new object[] {
             listName,
             displayName,
             parentType,
             fields,
             contentTypeProperties,
             addToView});
     return ((string)(results[0]));
 }