Example #1
0
        public void content_decorator_spa_trivial()
        {
            LoadDefault();

            var info = new PageLayoutInfo();

            info.Layouts.Add("content_decorator_spa_trivial_master_hxl");
            this.Data.SetProperty("pageLayoutInfo", info);
            GenerateAndAssert();
        }
Example #2
0
        public void content_decorator_spa_double_nesting()
        {
            LoadDefault();

            var info = new PageLayoutInfo();

            info.Layouts.Add("content_decorator_spa_double_nesting_fixture_inner_hxl");
            info.Layouts.Add("content_decorator_spa_double_nesting_fixture_outer_hxl");

            this.Data.SetProperty("pageLayoutInfo", info);
            GenerateAndAssert();
        }
Example #3
0
        internal bool IsDisabled(string placeholder, string location)
        {
            PageLayoutInfo layouts = TemplateContext.SinglePageLayoutInfo;

            if (layouts == null)
            {
                return(false);
            }

            string current;

            if (layouts.Locations.TryGetValue(placeholder, out current))
            {
                // Disabled if the location is the same
                return(current == location);
            }

            return(false);
        }
Example #4
0
        public void EnsurePage_WhenUpdatingAPage_GivenNewPageLayoutInfo_ThenExistingPageUsesTheNewPageLayout()
        {
            using (var testScope = SiteTestScope.PublishingSite())
            {
                var pagesLibrary = testScope.SiteCollection.RootWeb.GetPagesLibrary();
                var folder       = pagesLibrary.RootFolder;

                // Prepare the two page layouts. These are default SharePoint page Layouts.
                var initialPageLayoutInfo = new PageLayoutInfo("ArticleLeft.aspx", "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D");
                var finalPageLayoutInfo   = new PageLayoutInfo("ArticleRight.aspx", "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D");

                // Prepare the two page infos. This for one, better simulates running the same code twice, and second we can't change the page layout property directly.
                var pageFileName    = "TestPage";
                var initialPageInfo = new PageInfo(pageFileName, initialPageLayoutInfo);
                var updatedPageInfo = new PageInfo(pageFileName, finalPageLayoutInfo);

                using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(testScope.SiteCollection))
                {
                    var pageHelper = injectionScope.Resolve <IPageHelper>();

                    // Act

                    // Ensure the page with the initial page layout
                    PublishingPage initialPage = pageHelper.EnsurePage(pagesLibrary, folder, initialPageInfo);

                    // Re ensure the same page with the final pageLayoutInfo
                    PublishingPage updatedPage = pageHelper.EnsurePage(pagesLibrary, folder, updatedPageInfo);

                    // Assert

                    // Make sure the page layout has truely changed.
                    Assert.AreNotEqual(initialPage.Layout.ServerRelativeUrl, updatedPage.Layout.ServerRelativeUrl, "Page layout url should not be the same on the inital page as the updated page.");

                    // Make sure we are truely talking about the same page.
                    Assert.AreEqual(initialPage.Url, updatedPage.Url, "The initial page and updated page should have the same url.");
                }
            }
        }
Example #5
0
        public void EnsurePageLayout_WhenSettingTheAssociatedContentType_ThenThePageLayoutIsPublishedWithAMajorVersion()
        {
            using (var testScope = SiteTestScope.PublishingSite())
            {
                // Arrange

                // This page layout normally has article, we will set welcome page to it.
                var pageLayoutInfoWithUpdatedCT = new PageLayoutInfo("ArticleLeft.aspx", "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4");

                using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(testScope.SiteCollection))
                {
                    var pageHelper = injectionScope.Resolve <IPageHelper>();

                    // Act
                    var actualPageLayout = pageHelper.EnsurePageLayout(testScope.SiteCollection, pageLayoutInfoWithUpdatedCT);

                    // Assert
                    Assert.IsTrue(actualPageLayout != null);

                    var hasCurrentDraft = actualPageLayout.ListItem.Versions.Cast <SPListItemVersion>().Any(v => v.IsCurrentVersion && v.Level == SPFileLevel.Draft);
                    Assert.IsTrue(!hasCurrentDraft, "The page layout should not have a draft version marked as current.");
                }
            }
        }
Example #6
0
        public void FolderInfo_ShouldSupportStringSerializationAndDeserialization()
        {
            var serializer            = this.GetSerializer();
            var articleLeftPageLayout = new PageLayoutInfo("ArticleLeft.aspx", new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D"));
            var welcomePageLayout     = new PageLayoutInfo("WelcomeSplash.aspx", new SPContentTypeId("0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4"));

            var objectToSerialize = new FolderInfo("somepath")
            {
                Subfolders = new List <FolderInfo>()
                {
                    new FolderInfo("somelevel2path")
                    {
                        Pages = new List <PageInfo>()
                        {
                            new PageInfo("Hello-lvl-2-page-path", articleLeftPageLayout)
                            {
                                FieldValues = new List <FieldValueInfo>()
                                {
                                    new FieldValueInfo(PublishingFields.PublishingPageContent, "<div><p>Hi LVL 2!!! My HTML rocks!!!</p></div>")
                                },
                                WebParts = new[]
                                {
                                    new WebPartInfo("Main", new ContentEditorWebPart(), 5),
                                    new WebPartInfo("Main", new ContentEditorWebPart(), 10),
                                }
                            }
                        }
                    }
                },
                Pages = new List <PageInfo>()
                {
                    new PageInfo("Hello-root-page-path", welcomePageLayout)
                    {
                        FieldValues = new List <FieldValueInfo>()
                        {
                            new FieldValueInfo(PublishingFields.PublishingPageContent, "<div><p>My HTML rocks!!!</p></div>")
                        }
                    }
                }
            };

            string serializedRepresentation = serializer.Serialize(objectToSerialize);

            var deserializedObject = serializer.Deserialize <FolderInfo>(serializedRepresentation);

            Assert.AreEqual(objectToSerialize.Name, deserializedObject.Name);

            Assert.AreEqual(objectToSerialize.Pages.Count, deserializedObject.Pages.Count);
            Assert.AreEqual(objectToSerialize.Pages.ElementAt(0).FileName, deserializedObject.Pages.ElementAt(0).FileName);
            Assert.AreEqual(objectToSerialize.Pages.ElementAt(0).FieldValues.Count, deserializedObject.Pages.ElementAt(0).FieldValues.Count);
            Assert.AreEqual(
                objectToSerialize.Pages.ElementAt(0).FieldValues.ElementAt(0).FieldInfo.InternalName,
                deserializedObject.Pages.ElementAt(0).FieldValues.ElementAt(0).FieldInfo.InternalName);
            Assert.AreEqual(
                objectToSerialize.Pages.ElementAt(0).FieldValues.ElementAt(0).FieldInfo.AssociatedValueType,
                deserializedObject.Pages.ElementAt(0).FieldValues.ElementAt(0).FieldInfo.AssociatedValueType);
            Assert.AreEqual(
                objectToSerialize.Pages.ElementAt(0).FieldValues.ElementAt(0).Value,
                deserializedObject.Pages.ElementAt(0).FieldValues.ElementAt(0).Value);
            Assert.AreEqual(
                objectToSerialize.Pages.ElementAt(0).PageLayout.AssociatedContentTypeId,
                deserializedObject.Pages.ElementAt(0).PageLayout.AssociatedContentTypeId);

            Assert.AreEqual(objectToSerialize.Subfolders.Count, deserializedObject.Subfolders.Count);
            Assert.AreEqual(
                objectToSerialize.Subfolders.ElementAt(0).Pages.ElementAt(0).WebParts.Count,
                deserializedObject.Subfolders.ElementAt(0).Pages.ElementAt(0).WebParts.Count);
        }