コード例 #1
0
        public void CanDeploy_WebpartTo_CustomListViews_InList()
        {
            var model = SPMeta2Model
                        .NewWebModel(web =>
            {
                web
                .AddRandomList(list =>
                {
                    // custom with title only
                    list.AddRandomListView(listView =>
                    {
                        var def       = listView.Value as ListViewDefinition;
                        def.Url       = string.Empty;
                        def.IsDefault = false;

                        listView.AddRandomWebpart();
                        listView.AddRandomWebpart();
                    });

                    // custom with UTL
                    list.AddRandomListView(listView =>
                    {
                        var def       = listView.Value as ListViewDefinition;
                        def.Url       = Rnd.AspxFileName();
                        def.IsDefault = false;

                        listView.AddRandomWebpart();
                        listView.AddRandomWebpart();
                    });
                });
            });

            TestModel(model);
        }
コード例 #2
0
        public void CanDeploy_Default_PublishingPage_With_Content()
        {
            var siteFeature = BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(f => f.Enable());
            var webFeature  = BuiltInWebFeatures.SharePointServerPublishing.Inherit(f => f.Enable());

            var page = ModelGeneratorService.GetRandomDefinition <PublishingPageDefinition>(def =>
            {
                def.FileName = Rnd.AspxFileName();
                def.Content  = Rnd.String();
            });

            var siteModel = SPMeta2Model.NewSiteModel(site => site.AddSiteFeature(siteFeature));
            var webModel  = SPMeta2Model.NewWebModel(web =>
            {
                web.AddWebFeature(webFeature);
                web.AddHostList(BuiltInListDefinitions.Pages, list =>
                {
                    list.AddPublishingPage(page);
                });
            });

            TestModels(new ModelNode[] { siteModel, webModel });
        }
コード例 #3
0
        protected virtual void FillWebWithTheTestwebPartSuite <TWebpartType>(WebModelNode currentWeb)
            where TWebpartType : WebPartDefinitionBase, new()
        {
            var initialDef = ModelGeneratorService.GetRandomDefinition(typeof(TWebpartType)) as TWebpartType;

            var wikiWebPartDef           = initialDef.Clone <TWebpartType>();
            var webpartPageWebPartDef    = initialDef.Clone <TWebpartType>();
            var publishingPageWebPartDef = initialDef.Clone <TWebpartType>();

            // Some web part provision on wiki page give empty markup #693
            // https://github.com/SubPointSolutions/spmeta2/issues/693
            var webpartPageWebPartAddToPageContentDef1 = initialDef.Clone <TWebpartType>();

            webpartPageWebPartAddToPageContentDef1.Title            = Rnd.String();
            webpartPageWebPartAddToPageContentDef1.Id               = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
            webpartPageWebPartAddToPageContentDef1.ZoneId           = "wpz";
            webpartPageWebPartAddToPageContentDef1.AddToPageContent = true;

            var webpartPageWebPartAddToPageContentDef2 = initialDef.Clone <TWebpartType>();

            webpartPageWebPartAddToPageContentDef2.Title            = Rnd.String();
            webpartPageWebPartAddToPageContentDef2.Id               = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
            webpartPageWebPartAddToPageContentDef2.ZoneId           = "wpz";
            webpartPageWebPartAddToPageContentDef2.AddToPageContent = true;

            var listWebPartDef = initialDef.Clone <TWebpartType>();
            var docWebPartDef  = initialDef.Clone <TWebpartType>();

            // ensure for the client web part
            currentWeb.AddRandomApp();

            currentWeb
            /// for the Pages lib & pubnlishing pages
            .AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(def =>
            {
                def.Enable        = true;
                def.ForceActivate = true;
            }))

            .AddHostList(BuiltInListDefinitions.SitePages, list =>
            {
                var webpartPageName = string.Empty;
                var wikiPageName    = string.Empty;
                var wikiPageNameAddToPageContent = string.Empty;

                if (UseWikiPages)
                {
                    list
                    // 1 - wiki pages
                    .AddRandomWikiPage(page =>
                    {
                        wikiPageName = (page.Value as WikiPageDefinition).FileName;
                        page.AddDefinitionNode(wikiWebPartDef);
                    });

                    ValidateWebPartPresenceForPage(list, wikiPageName, wikiWebPartDef);
                }

                if (UseWebPartPages)
                {
                    list
                    // 2- web part pages
                    .AddRandomWebPartPage(page =>
                    {
                        webpartPageName = (page.Value as WebPartPageDefinition).FileName;
                        page.AddDefinitionNode(webpartPageWebPartDef);
                    });

                    ValidateWebPartPresenceForPage(list, webpartPageName, webpartPageWebPartDef);
                }

                if (UseWikiPages)
                {
                    list
                    /// 3- adding to the web part page as .AddToPageContent
                    .AddRandomWikiPage(page =>
                    {
                        page.RegExcludeFromValidation();

                        wikiPageNameAddToPageContent = (page.Value as WikiPageDefinition).FileName;

                        page.AddDefinitionNode(webpartPageWebPartAddToPageContentDef1);
                        page.AddDefinitionNode(webpartPageWebPartAddToPageContentDef2);
                    });

                    ValidateWebPartPresenceForPage(list, wikiPageNameAddToPageContent, webpartPageWebPartAddToPageContentDef1);
                    ValidateWebPartPresenceForPage(list, wikiPageNameAddToPageContent, webpartPageWebPartAddToPageContentDef2);
                }
            });

            // 3 - publishing pages
            currentWeb.AddHostList(BuiltInListDefinitions.Pages, list =>
            {
                var publishingPageName = string.Empty;

                if (UsePublishingPages)
                {
                    list
                    .AddRandomPublishingPage(page =>
                    {
                        (page.Value as PublishingPageDefinition).PageLayoutFileName =
                            BuiltInPublishingPageLayoutNames.BlankWebPartPage;
                        publishingPageName = (page.Value as PublishingPageDefinition).FileName;

                        page.AddDefinitionNode(publishingPageWebPartDef);
                    });

                    ValidateWebPartPresenceForPage(list, publishingPageName, publishingPageWebPartDef);
                }
            });

            if (UseListPages)
            {
                // 4 - list related routines - OOTB views, custom views & forms
                currentWeb.AddRandomList(list =>
                {
                    // OOTB view
                    list.AddHostListView(BuiltInListViewDefinitions.Lists.AllItems, listView =>
                    {
                        listView.AddDefinitionNode(listWebPartDef.Inherit());
                    });

                    if (ShoudValidatePresenceOnListViews(initialDef))
                    {
                        ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.AllItems.Url, listWebPartDef);
                    }

                    // custom view
                    var customView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
                    {
                        def.Url = Rnd.AspxFileName();
                    });

                    list.AddListView(customView, listView =>
                    {
                        listView.AddDefinitionNode(listWebPartDef.Inherit());
                    });

                    if (ShoudValidatePresenceOnListViews(initialDef))
                    {
                        ValidateWebPartPresenceForPage(list, customView.Url, listWebPartDef);
                    }

                    // OOTB forms, new - edit - view
                    list.AddHostListView(BuiltInListViewDefinitions.Lists.NewForm, listView =>
                    {
                        listView.AddDefinitionNode(listWebPartDef.Inherit());
                    });

                    ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.NewForm.Url, listWebPartDef);

                    list.AddHostListView(BuiltInListViewDefinitions.Lists.EditForm, listView =>
                    {
                        listView.AddDefinitionNode(listWebPartDef.Inherit());
                    });


                    ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.EditForm.Url, listWebPartDef);

                    list.AddHostListView(BuiltInListViewDefinitions.Lists.DispForm, listView =>
                    {
                        listView.AddDefinitionNode(listWebPartDef.Inherit());
                    });


                    ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.DispForm.Url, listWebPartDef);
                });
            }

            if (UseLibraryPages)
            {
                // 5 - OOTB list view form on the library
                currentWeb.AddRandomDocumentLibrary(list =>
                {
                    // OOTB view

                    list.AddHostListView(BuiltInListViewDefinitions.Libraries.AllItems, listView =>
                    {
                        listView.AddDefinitionNode(docWebPartDef.Inherit());
                    });

                    if (ShoudValidatePresenceOnLibraryViews(initialDef))
                    {
                        ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.AllItems.Url, docWebPartDef);
                    }

                    // custom view
                    var customView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
                    {
                        def.Url = Rnd.AspxFileName();
                    });

                    list.AddListView(customView, listView =>
                    {
                        listView.AddDefinitionNode(docWebPartDef.Inherit());
                    });

                    if (ShoudValidatePresenceOnLibraryViews(initialDef))
                    {
                        ValidateWebPartPresenceForPage(list, "Forms/" + customView.Url, docWebPartDef);
                    }

                    // OOTB new - edit - view forms
                    // upload, NOPE!
                    //list.AddHostListView(BuiltInListViewDefinitions.Libraries.Upload, listView =>
                    //{
                    //    listView.AddDefinitionNode(docWebPartDef.Inherit());
                    //});

                    //ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.Upload.Url, docWebPartDef);

                    list.AddHostListView(BuiltInListViewDefinitions.Libraries.EditForm, listView =>
                    {
                        listView.AddDefinitionNode(docWebPartDef.Inherit());
                    });

                    ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.EditForm.Url, docWebPartDef);

                    list.AddHostListView(BuiltInListViewDefinitions.Libraries.DispForm, listView =>
                    {
                        listView.AddDefinitionNode(docWebPartDef.Inherit());
                    });

                    ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.DispForm.Url, docWebPartDef);
                });
            }
            ;

            // all web parts chrom
            currentWeb.WithNodesOfType <WebPartDefinitionBase>(node =>
            {
                var wp = node.Value as WebPartDefinitionBase;

                wp.ChromeType  = BuiltInPartChromeType.TitleAndBorder;
                wp.ChromeState = BuiltInPartChromeState.Normal;
            });
        }
コード例 #4
0
        protected virtual void FillWebWithTheTestwebPartSuite <TWebpartType>(WebModelNode currentWeb)
            where TWebpartType : WebPartDefinitionBase, new()
        {
            var initialDef = ModelGeneratorService.GetRandomDefinition(typeof(TWebpartType)) as TWebpartType;

            var wikiWebPartDef           = initialDef.Clone <TWebpartType>();
            var webpartPageWebPartDef    = initialDef.Clone <TWebpartType>();
            var publishingPageWebPartDef = initialDef.Clone <TWebpartType>();

            var listWebPartDef = initialDef.Clone <TWebpartType>();
            var docWebPartDef  = initialDef.Clone <TWebpartType>();

            // ensure for the client web part
            currentWeb.AddRandomApp();

            currentWeb
            /// for the Pages lib & pubnlishing pages
            .AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(def =>
            {
                def.Enable = true;
            }))

            .AddHostList(BuiltInListDefinitions.SitePages, list =>
            {
                var webpartPageName = string.Empty;
                var wikiPageName    = string.Empty;

                list
                // 1 - wiki pages
                .AddRandomWikiPage(page =>
                {
                    wikiPageName = (page.Value as WikiPageDefinition).FileName;
                    page.AddDefinitionNode(wikiWebPartDef);
                })
                // 2- web part pages
                .AddRandomWebPartPage(page =>
                {
                    webpartPageName = (page.Value as WebPartPageDefinition).FileName;
                    page.AddDefinitionNode(webpartPageWebPartDef);
                });

                ValidateWebPartPresenceForPage(list, wikiPageName, wikiWebPartDef);
                ValidateWebPartPresenceForPage(list, webpartPageName, webpartPageWebPartDef);
            })
            // 3 - publishing pages
            .AddHostList(BuiltInListDefinitions.Pages, list =>
            {
                var publishingPageName = string.Empty;

                list
                .AddRandomPublishingPage(page =>
                {
                    (page.Value as PublishingPageDefinition).PageLayoutFileName =
                        BuiltInPublishingPageLayoutNames.BlankWebPartPage;
                    publishingPageName = (page.Value as PublishingPageDefinition).FileName;

                    page.AddDefinitionNode(publishingPageWebPartDef);
                });

                ValidateWebPartPresenceForPage(list, publishingPageName, publishingPageWebPartDef);
            })
            // 4 - list related routines - OOTB views, custom views & forms
            .AddRandomList(list =>
            {
                // OOTB view
                list.AddHostListView(BuiltInListViewDefinitions.Lists.AllItems, listView =>
                {
                    listView.AddDefinitionNode(listWebPartDef.Inherit());
                });

                if (ShoudValidatePresenceOnListViews(initialDef))
                {
                    ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.AllItems.Url, listWebPartDef);
                }

                // custom view
                var customView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
                {
                    def.Url = Rnd.AspxFileName();
                });

                list.AddListView(customView, listView =>
                {
                    listView.AddDefinitionNode(listWebPartDef.Inherit());
                });

                if (ShoudValidatePresenceOnListViews(initialDef))
                {
                    ValidateWebPartPresenceForPage(list, customView.Url, listWebPartDef);
                }

                // OOTB forms, new - edit - view
                list.AddHostListView(BuiltInListViewDefinitions.Lists.NewForm, listView =>
                {
                    listView.AddDefinitionNode(listWebPartDef.Inherit());
                });

                ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.NewForm.Url, listWebPartDef);

                list.AddHostListView(BuiltInListViewDefinitions.Lists.EditForm, listView =>
                {
                    listView.AddDefinitionNode(listWebPartDef.Inherit());
                });


                ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.EditForm.Url, listWebPartDef);

                list.AddHostListView(BuiltInListViewDefinitions.Lists.DispForm, listView =>
                {
                    listView.AddDefinitionNode(listWebPartDef.Inherit());
                });


                ValidateWebPartPresenceForPage(list, BuiltInListViewDefinitions.Lists.DispForm.Url, listWebPartDef);
            })

            // 5 - OOTB list view form on the library
            .AddRandomDocumentLibrary(list =>
            {
                // OOTB view

                list.AddHostListView(BuiltInListViewDefinitions.Libraries.AllItems, listView =>
                {
                    listView.AddDefinitionNode(docWebPartDef.Inherit());
                });

                if (ShoudValidatePresenceOnLibraryViews(initialDef))
                {
                    ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.AllItems.Url, docWebPartDef);
                }

                // custom view
                var customView = ModelGeneratorService.GetRandomDefinition <ListViewDefinition>(def =>
                {
                    def.Url = Rnd.AspxFileName();
                });

                list.AddListView(customView, listView =>
                {
                    listView.AddDefinitionNode(docWebPartDef.Inherit());
                });

                if (ShoudValidatePresenceOnLibraryViews(initialDef))
                {
                    ValidateWebPartPresenceForPage(list, "Forms/" + customView.Url, docWebPartDef);
                }

                // OOTB new - edit - view forms
                // upload, NOPE!
                //list.AddHostListView(BuiltInListViewDefinitions.Libraries.Upload, listView =>
                //{
                //    listView.AddDefinitionNode(docWebPartDef.Inherit());
                //});

                //ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.Upload.Url, docWebPartDef);

                list.AddHostListView(BuiltInListViewDefinitions.Libraries.EditForm, listView =>
                {
                    listView.AddDefinitionNode(docWebPartDef.Inherit());
                });

                ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.EditForm.Url, docWebPartDef);

                list.AddHostListView(BuiltInListViewDefinitions.Libraries.DispForm, listView =>
                {
                    listView.AddDefinitionNode(docWebPartDef.Inherit());
                });

                ValidateWebPartPresenceForPage(list, "Forms/" + BuiltInListViewDefinitions.Libraries.DispForm.Url, docWebPartDef);
            });
            ;

            // all web parts chrom
            currentWeb.WithNodesOfType <WebPartDefinitionBase>(node =>
            {
                var wp = node.Value as WebPartDefinitionBase;

                wp.ChromeType  = BuiltInPartChromeType.TitleAndBorder;
                wp.ChromeState = BuiltInPartChromeState.Normal;
            });
        }