Esempio n. 1
0
        public void CanDeploy_SandboxSiteFeature()
        {
            var sandboxSolution = new SandboxSolutionDefinition()
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("e9a61998-07f2-45e9-ae43-9e93fa6b11bb"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Regression.Tests.Templates.SandboxSolutions.SPMeta2.Containers.SandboxSolutionContainer.wsp")
            };

            var model = SPMeta2Model
                        .NewSiteModel(site =>
            {
                site.AddSandboxSolution(sandboxSolution);

                site.AddFeature(new FeatureDefinition
                {
                    Enable        = true,
                    ForceActivate = true,
                    Id            = new Guid("32dc6bed-0298-4fca-a72f-e9b9c0d6f09a"),
                    Scope         = FeatureDefinitionScope.Site
                });
            });

            TestModel(model);
        }
Esempio n. 2
0
        public void CanDeploy_SandboxWebFeature()
        {
            var sandboxSolution = new SandboxSolutionDefinition()
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("e9a61998-07f2-45e9-ae43-9e93fa6b11bb"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Regression.Tests.Templates.SandboxSolutions.SPMeta2.Containers.SandboxSolutionContainer.wsp")
            };

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSandboxSolution(sandboxSolution);
            });

            var model = SPMeta2Model
                        .NewWebModel(web =>
            {
                web.AddFeature(new FeatureDefinition
                {
                    Enable        = true,
                    ForceActivate = true,
                    Id            = new Guid("b997a462-8efb-44cf-92c0-457e75c81798"),
                    Scope         = FeatureDefinitionScope.Web
                });
            });

            TestModel(siteModel, model);
        }
Esempio n. 3
0
        public void CanDeploy_SandboxWebFeature()
        {
            var sandboxSolution = new SandboxSolutionDefinition()
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("9f581901-7ed8-4293-9d48-c526ad5a3d7d"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Regression.Tests.Templates.SandboxSolutions.SPMeta2.ScenarioTest.SandboxApp.wsp")
            };

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddSandboxSolution(sandboxSolution);
            });

            var model = SPMeta2Model
                        .NewWebModel(web =>
            {
                web.AddFeature(new FeatureDefinition
                {
                    Enable        = true,
                    ForceActivate = true,
                    Id            = new Guid("e4a8e1de-6688-493b-ad7a-d35c0268550c"),
                    Scope         = FeatureDefinitionScope.Web
                });
            });

            TestModel(siteModel, model);
        }
Esempio n. 4
0
        public void CanDeploy_SandboxSiteFeature()
        {
            var sandboxSolution = new SandboxSolutionDefinition()
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("9f581901-7ed8-4293-9d48-c526ad5a3d7d"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Regression.Tests.Templates.SandboxSolutions.SPMeta2.ScenarioTest.SandboxApp.wsp")
            };

            var model = SPMeta2Model
                        .NewSiteModel(site =>
            {
                site.AddSandboxSolution(sandboxSolution);

                site.AddFeature(new FeatureDefinition
                {
                    Enable        = true,
                    ForceActivate = true,
                    Id            = new Guid("167dc650-68d2-4784-bd5b-9c6709db4ac6"),
                    Scope         = FeatureDefinitionScope.Site
                });
            });

            TestModel(model);
        }
Esempio n. 5
0
        //[SampleMetadataTag(Name = BuiltInTagNames.SampleHidden)]
        public void CanDeployUserCustomActionWithJquery()
        {
            var jQueryFile = new ModuleFileDefinition
            {
                FileName  = "jquery-1.11.2.min.js",
                Content   = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Docs.Modules.jquery-1.11.2.min.js"),
                Overwrite = true
            };

            var appScriptsFolder = new FolderDefinition
            {
                Name = "M2 App Scripts"
            };

            var jQueryCustomAction = new UserCustomActionDefinition
            {
                Name      = "m2jQuery",
                Location  = "ScriptLink",
                ScriptSrc = UrlUtility.CombineUrl(new string[]
                {
                    "~sitecollection",
                    BuiltInListDefinitions.StyleLibrary.GetListUrl(),
                    appScriptsFolder.Name,
                    jQueryFile.FileName
                }),
                Sequence = 1500
            };

            var jQuerySiteLogger = new UserCustomActionDefinition
            {
                Name        = "m2jQuerySiteLogger",
                Location    = "ScriptLink",
                ScriptBlock = "jQuery(document).ready( function() { console.log('jQuery site logger on site:' + _spPageContextInfo.siteAbsoluteUrl); } );",
                Sequence    = 1600
            };

            var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site
                .AddUserCustomAction(jQueryCustomAction)
                .AddUserCustomAction(jQuerySiteLogger);
            });

            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddHostList(BuiltInListDefinitions.StyleLibrary, list =>
                {
                    list.AddFolder(appScriptsFolder, folder =>
                    {
                        folder.AddModuleFile(jQueryFile);
                    });
                });
            });

            DeployModel(siteModel);
            DeployModel(webModel);
        }
        public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action)
        {
            return(WithEmptyDefinition(def =>
            {
                def.FileName = string.Format("{0}.wsp", Rnd.String());
                def.SolutionId = new Guid("9591a597-da94-47b4-a3c6-2f8703d4de2b");

                def.Content = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Containers.Templates.Apps.SPMeta2.Sandbox.TestFarmApp.wsp");
            }));
        }
Esempio n. 7
0
        public void CanDeploy_List_From_CustomTemplate()
        {
            var sandboxSolution = new SandboxSolutionDefinition()
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("e9a61998-07f2-45e9-ae43-9e93fa6b11bb"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Regression.Tests.Templates.SandboxSolutions.SPMeta2.Containers.SandboxSolutionContainer.wsp")
            };

            var customListDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType  = BuiltInListTemplateTypeId.GenericList;
                def.ForceCheckout = false;

#pragma warning disable 618
                def.Url = Rnd.String();
#pragma warning restore 618
                def.CustomUrl = string.Empty;

                // would give invalid list template exception
                //def.TemplateType = 10500;

                // works well, just reset TemplateType as GetRandomDefinition<> generated random TemplateType
                def.TemplateType = 0;
                def.TemplateName = "CustomerList";
            });

            var siteModel = SPMeta2Model
                            .NewSiteModel(site =>
            {
                site.AddSandboxSolution(sandboxSolution);
            });

            var webModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web.AddRandomWeb(subWeb =>
                {
                    subWeb.AddWebFeature(new FeatureDefinition
                    {
                        Id            = new Guid("b997a462-8efb-44cf-92c0-457e75c81798"),
                        Scope         = FeatureDefinitionScope.Web,
                        Enable        = true,
                        ForceActivate = true
                    });

                    subWeb.AddList(customListDef);
                });
            });

            TestModel(siteModel, webModel);
        }
Esempio n. 8
0
        public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action)
        {
            return(WithEmptyDefinition(def =>
            {
                def.FileName = string.Format("{0}.wsp", Rnd.String());
                def.Activate = Rnd.Bool();

                def.SolutionId = new Guid("e34d1ce3-62da-4a73-a382-a49af8e5dde0");
                def.Content = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Containers.Templates.Apps.SPMeta2.Sandbox.TestSandboxApp.wsp");
            }));
        }
Esempio n. 9
0
        public override DefinitionBase GenerateRandomDefinition(Action <DefinitionBase> action)
        {
            return(WithEmptyDefinition(def =>
            {
                def.FileName = string.Format("{0}.wsp", Rnd.String());
                def.Activate = true;

                def.SolutionId = new Guid("e9a61998-07f2-45e9-ae43-9e93fa6b11bb");
                def.Content = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Containers.Templates.Apps.SPMeta2.Containers.SandboxSolutionContainer.wsp");
            }));
        }
Esempio n. 10
0
        public void CanDeploy_List_From_STPListTemplate()
        {
            var stpTemplateContent = ModuleFileUtils.FromResource(
                GetType().Assembly,
                "SPMeta2.Regression.Tests.Templates.STP.M2Template.stp");

            var stpTemplateFeatureId = new Guid("{00BFEA71-DE22-43B2-A848-C05709900100}");

            // upload stp to list templates
            var stpModel = SPMeta2Model
                           .NewWebModel(web =>
            {
                web.AddHostList(BuiltInListDefinitions.Catalogs.ListTemplates, list =>
                {
                    list.AddModuleFile(new ModuleFileDefinition
                    {
                        FileName = "M2Template.stp",
                        Content  = stpTemplateContent
                    });
                });
            });

            var customListDef = ModelGeneratorService.GetRandomDefinition <ListDefinition>(def =>
            {
                def.TemplateType  = BuiltInListTemplateTypeId.GenericList;
                def.ForceCheckout = false;

#pragma warning disable 618
                def.Url = Rnd.String();
#pragma warning restore 618
                def.CustomUrl = string.Empty;

                def.TemplateType = 0;
                def.TemplateName = "M2Template";
            });

            // deploy template to both current and sub web
            var webModel = SPMeta2Model.NewWebModel(web =>
            {
                web.AddList(customListDef.Inherit <ListDefinition>());

                web.AddRandomWeb(subWeb =>
                {
                    subWeb.AddList(customListDef.Inherit <ListDefinition>());
                });
            });

            TestModel(stpModel, webModel);
        }
        public override IEnumerable <DefinitionBase> GetAdditionalArtifacts()
        {
            var sandboxSolution = new SandboxSolutionDefinition
            {
                FileName = string.Format("{0}.wsp", Rnd.String()),
                Activate = true,

                SolutionId = new Guid("e9a61998-07f2-45e9-ae43-9e93fa6b11bb"),
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "SPMeta2.Containers.Templates.Apps.SPMeta2.Containers.SandboxSolutionContainer.wsp")
            };

            var webpartFeature = new FeatureDefinition
            {
                Scope  = FeatureDefinitionScope.Site,
                Id     = new Guid("9acf0f59-3cdc-412b-a647-4185dd4cd9bc"),
                Enable = true
            };

            return(new DefinitionBase[] { sandboxSolution, webpartFeature });
        }
        //[SampleMetadataTag(Name = BuiltInTagNames.SampleHidden)]
        public void CanDeploySimpleSandboxSolutionDefinition()
        {
            // FileName could be different to the original solution name
            // FileName must not have "." to avoid fails (DesignPackage API limitations)

            // Content is a byte array, so get ot from whatever source you want

            // SolutionId is used to lookup existing sandbox package
            // get SolutionId from the VS project or XML inside WSP package

            // Activate must be always true for CSOM (DesignPackage API limitations)

            var myBranding = new SandboxSolutionDefinition
            {
                FileName   = "MyBranding.wsp",
                Content    = File.ReadAllBytes("MySandboxBranding.wsp"),
                SolutionId = new Guid("0CDCC076-A472-4DD9-9A1F-0E1E761ED61D"),
                Activate   = true,
            };

            var myTasks = new SandboxSolutionDefinition
            {
                FileName   = "MyTasks.wsp",
                Content    = ModuleFileUtils.FromResource(GetType().Assembly, "MyIntranet.Resources.MyTasks.wsp"),
                SolutionId = new Guid("3D279748-92FC-49F9-A6C5-A10FBCD2DB24"),
                Activate   = true,
            };

            var model = SPMeta2Model.NewSiteModel(site =>
            {
                site
                .AddSandboxSolution(myBranding)
                .AddSandboxSolution(myTasks);
            });

            DeployModel(model);
        }