public void CanCreateEntities()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                var template = new ProvisioningTemplate();
                template = new ObjectContentType().CreateEntities(ctx.Web, template, null);

                Assert.IsTrue(template.ContentTypes.Any());
                Assert.IsInstanceOfType(template.ContentTypes, typeof(List <ContentType>));
            }
        }
        public void CanCreateEntities()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                // Load the base template which will be used for the comparison work
                var creationInfo = new ProvisioningTemplateCreationInformation(ctx.Web)
                {
                    BaseTemplate = ctx.Web.GetBaseTemplate()
                };

                var template = new ProvisioningTemplate();
                template = new ObjectContentType().CreateEntities(ctx.Web, template, creationInfo);

                Assert.IsTrue(template.ContentTypes.Any());
                Assert.IsInstanceOfType(template.ContentTypes, typeof(List <ContentType>));
            }
        }
        public void CanCreateEntities()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                // Provision a test content type
                var ct = ctx.Web.GetContentTypeByName("Test Content Type");
                if (ct == null)
                {
                    var provisionTemplate = new ProvisioningTemplate();
                    var contentType       = new ContentType()
                    {
                        Id          = "0x010100503B9E20E5455344BFAC2292DC6FE805",
                        Name        = "Test Content Type",
                        Group       = "PnP",
                        Description = "Test Description",
                        Overwrite   = true,
                        Hidden      = false
                    };

                    contentType.FieldRefs.Add(new FieldRef()
                    {
                        Id          = BuiltInFieldId.Category,
                        DisplayName = "Test Category",
                    });
                    provisionTemplate.ContentTypes.Add(contentType);
                    TokenParser parser = new TokenParser(ctx.Web, provisionTemplate);
                    new ObjectContentType().ProvisionObjects(ctx.Web, provisionTemplate, parser, new ProvisioningTemplateApplyingInformation());
                }

                // Load the base template which will be used for the comparison work
                var creationInfo = new ProvisioningTemplateCreationInformation(ctx.Web)
                {
                    BaseTemplate = ctx.Web.GetBaseTemplate()
                };

                var template = new ProvisioningTemplate();
                template = new ObjectContentType().ExtractObjects(ctx.Web, template, creationInfo);

                Assert.IsTrue(template.ContentTypes.Any());
                Assert.IsInstanceOfType(template.ContentTypes, typeof(Core.Framework.Provisioning.Model.ContentTypeCollection));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Add content type filter
 /// </summary>
 /// <returns>content_type__component</returns>
 public void AddFilter(ObjectContentType contentType)
 {
     _filters.Add(new KeyValuePair <string, string>("content_type__component", contentType.GetDescription()));
 }