Esempio n. 1
0
        public void CanProvisionSupportedUILanguages()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanProvisionSupportedUILanguages"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate();

                    template.SupportedUILanguages.Add(new SupportedUILanguage()
                    {
                        LCID = 1033
                    });                                                                           // English
                    template.SupportedUILanguages.Add(new SupportedUILanguage()
                    {
                        LCID = 1032
                    });                                                                           // Greek

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectSupportedUILanguages().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    ctx.Load(ctx.Web, w => w.SupportedUILanguageIds);

                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Count() == 2);
                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Any(i => i == 1033));
                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Any(i => i == 1032));
                }
            }
        }
        public void CanProvisionRegionalSettings()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanProvisionRegionalSettings"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate
                    {
                        RegionalSettings = new PnP.Framework.Provisioning.Model.RegionalSettings
                        {
                            FirstDayOfWeek = System.DayOfWeek.Monday,
                            WorkDayEndHour = WorkHour.PM0700,
                            TimeZone       = 5,
                            Time24         = true
                        }
                    };

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectRegionalSettings().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    ctx.Load(ctx.Web.RegionalSettings);
                    ctx.Load(ctx.Web.RegionalSettings.TimeZone, tz => tz.Id);
                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(ctx.Web.RegionalSettings.Time24);
                    Assert.IsTrue(ctx.Web.RegionalSettings.WorkDayEndHour == (short)WorkHour.PM0700);
                    Assert.IsTrue(ctx.Web.RegionalSettings.FirstDayOfWeek == (uint)System.DayOfWeek.Monday);
                    Assert.IsTrue(ctx.Web.RegionalSettings.TimeZone.Id == 5);
                }
            }
        }
        public void CanProvisionAuditSettings()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanProvisionAuditSettings"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate
                    {
                        AuditSettings = new AuditSettings
                        {
                            AuditFlags = AuditMaskType.CheckIn,
                            AuditLogTrimmingRetention = 5,
                            TrimAuditLog = true
                        }
                    };

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectAuditSettings().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    var site = ctx.Site;

                    var auditSettings = site.Audit;
                    ctx.Load(auditSettings, af => af.AuditFlags);
                    ctx.Load(site, s => s.AuditLogTrimmingRetention, s => s.TrimAuditLog);
                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(auditSettings.AuditFlags == AuditMaskType.CheckIn);
                    Assert.IsTrue(site.AuditLogTrimmingRetention == 5);
                    Assert.IsTrue(site.TrimAuditLog = true);
                }
            }
        }
        public void CanCreateComposedLooks()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("ComposedLookTests"))
            {
                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 ObjectComposedLook().ExtractObjects(ctx.Web, template, creationInfo);
                    Assert.IsInstanceOfType(template.ComposedLook, typeof(PnP.Framework.Provisioning.Model.ComposedLook));
                }
            }
        }
        public void CanExtractAuditSettings()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanExtractAuditSettings"))
            {
                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 ObjectAuditSettings().ExtractObjects(ctx.Web, template, creationInfo);

                    Assert.IsNotNull(template.AuditSettings);
                }
            }
        }
Esempio n. 6
0
        public void CanExtractSupportedUILanguages()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanProvisionSupportedUILanguages"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var creationInfo = new ProvisioningTemplateCreationInformation(ctx.Web)
                    {
                        BaseTemplate = null
                    };

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

                    Assert.IsTrue(template.SupportedUILanguages.Count > 0);
                }
            }
        }
        public void CanExtractRegionalSettings()
        {
            using (var scope = new PnP.Framework.Diagnostics.PnPMonitoredScope("CanExtractRegionalSettings"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    // do not set the base template as that will mean that regional settings are not extracted
                    // when the test site has the same regional settings as the base template had
                    var creationInfo = new ProvisioningTemplateCreationInformation(ctx.Web)
                    {
                        BaseTemplate = null
                    };

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

                    Assert.IsNotNull(template.RegionalSettings);
                }
            }
        }