コード例 #1
0
        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();

            var propbagEntry = new Core.Framework.Provisioning.Model.PropertyBagEntry();
            propbagEntry.Key = key;
            propbagEntry.Value = "Unit Test";

            template.PropertyBagEntries.Add(propbagEntry);

            using (var ctx = TestCommon.CreateClientContext())
            {
                new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template);

                var value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");
            }
        }
コード例 #2
0
        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();


            var propbagEntry = new Core.Framework.Provisioning.Model.PropertyBagEntry();

            propbagEntry.Key   = key;
            propbagEntry.Value = "Unit Test";

            template.PropertyBagEntries.Add(propbagEntry);

            using (var ctx = TestCommon.CreateClientContext())
            {
                new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template);

                var value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");
            }
        }
コード例 #3
0
        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();

            var propbagEntry = new Core.Framework.Provisioning.Model.PropertyBagEntry();
            propbagEntry.Key = key;
            propbagEntry.Value = "Unit Test";

            template.PropertyBagEntries.Add(propbagEntry);

            using (var ctx = TestCommon.CreateClientContext())
            {
                var parser = new TokenParser(ctx.Web, template);
                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                var value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");

                // Create same entry, but don't overwrite.
                template = new ProvisioningTemplate();

                var propbagEntry2 = new PropertyBagEntry();
                propbagEntry2.Key = key;
                propbagEntry2.Value = "Unit Test 2";
                propbagEntry2.Overwrite = false;

                template.PropertyBagEntries.Add(propbagEntry2);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");


                // Create same entry, but overwrite
                template = new ProvisioningTemplate();

                var propbagEntry3 = new PropertyBagEntry();
                propbagEntry3.Key = key;
                propbagEntry3.Value = "Unit Test 3";
                propbagEntry3.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry3);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test 3");

                // Create entry with system key. We don't specify to overwrite system keys, so the key should not be created.
                template = new ProvisioningTemplate();

                var propbagEntry4 = new PropertyBagEntry();
                propbagEntry4.Key = systemKey;
                propbagEntry4.Value = "Unit Test System Key";
                propbagEntry4.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry4);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsTrue(value == "default");

                // Create entry with system key. We _do_ specify to overwrite system keys, so the key should be created.
                template = new ProvisioningTemplate();

                var propbagEntry5 = new PropertyBagEntry();
                propbagEntry5.Key = systemKey;
                propbagEntry5.Value = "Unit Test System Key 5";
                propbagEntry5.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry5);

                parser = new  ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation() { OverwriteSystemPropertyBagValues = true});

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsTrue(value == "Unit Test System Key 5");

                // Create entry with system key. We _do not_ specify to overwrite system keys, so the key should not be created.
                template = new ProvisioningTemplate();

                var propbagEntry6 = new PropertyBagEntry();
                propbagEntry6.Key = systemKey;
                propbagEntry6.Value = "Unit Test System Key 6";
                propbagEntry6.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry6);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation() { OverwriteSystemPropertyBagValues = false });

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsFalse(value == "Unit Test System Key 6");
            }
        }
コード例 #4
0
        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();

            var propbagEntry = new Core.Framework.Provisioning.Model.PropertyBagEntry();

            propbagEntry.Key   = key;
            propbagEntry.Value = "Unit Test";

            template.PropertyBagEntries.Add(propbagEntry);

            using (var ctx = TestCommon.CreateClientContext())
            {
                var parser = new TokenParser(ctx.Web, template);
                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                var value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");

                // Create same entry, but don't overwrite.
                template = new ProvisioningTemplate();

                var propbagEntry2 = new PropertyBagEntry();
                propbagEntry2.Key       = key;
                propbagEntry2.Value     = "Unit Test 2";
                propbagEntry2.Overwrite = false;

                template.PropertyBagEntries.Add(propbagEntry2);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test");


                // Create same entry, but overwrite
                template = new ProvisioningTemplate();

                var propbagEntry3 = new PropertyBagEntry();
                propbagEntry3.Key       = key;
                propbagEntry3.Value     = "Unit Test 3";
                propbagEntry3.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry3);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(key, "default");
                Assert.IsTrue(value == "Unit Test 3");

                // Create entry with system key. We don't specify to overwrite system keys, so the key should not be created.
                template = new ProvisioningTemplate();

                var propbagEntry4 = new PropertyBagEntry();
                propbagEntry4.Key       = systemKey;
                propbagEntry4.Value     = "Unit Test System Key";
                propbagEntry4.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry4);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsTrue(value == "default");

                // Create entry with system key. We _do_ specify to overwrite system keys, so the key should be created.
                template = new ProvisioningTemplate();

                var propbagEntry5 = new PropertyBagEntry();
                propbagEntry5.Key       = systemKey;
                propbagEntry5.Value     = "Unit Test System Key 5";
                propbagEntry5.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry5);

                parser = new  ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()
                {
                    OverwriteSystemPropertyBagValues = true
                });

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsTrue(value == "Unit Test System Key 5");

                // Create entry with system key. We _do not_ specify to overwrite system keys, so the key should not be created.
                template = new ProvisioningTemplate();

                var propbagEntry6 = new PropertyBagEntry();
                propbagEntry6.Key       = systemKey;
                propbagEntry6.Value     = "Unit Test System Key 6";
                propbagEntry6.Overwrite = true;

                template.PropertyBagEntries.Add(propbagEntry6);

                parser = new ObjectPropertyBagEntry().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()
                {
                    OverwriteSystemPropertyBagValues = false
                });

                value = ctx.Web.GetPropertyBagValueString(systemKey, "default");
                Assert.IsFalse(value == "Unit Test System Key 6");
            }
        }