예제 #1
0
        public void PageLayoutAnalyse_AnalyseSingleWithOutput()
        {
            using (var sourceClientContext = TestCommon.CreateClientContext())
            {
                // Source Context could be a site collection
                ClientContext contextToUse;
                if (sourceClientContext.Web.IsSubSite())
                {
                    string siteCollectionUrl = sourceClientContext.Site.EnsureProperty(o => o.Url);
                    contextToUse = sourceClientContext.Clone(siteCollectionUrl);
                }
                else
                {
                    contextToUse = sourceClientContext;
                }

                var pageLayoutAnalyser = new PageLayoutAnalyser(sourceClientContext);
                pageLayoutAnalyser.RegisterObserver(new UnitTestLogObserver());

                var layout = contextToUse.Web.GetFileByServerRelativeUrl($"{contextToUse.Web.EnsureProperty(o => o.ServerRelativeUrl)}/_catalogs/masterpage/ArticleCustom.aspx");

                var result = string.Empty;
                if (layout != null)
                {
                    ListItem item = layout.EnsureProperty(o => o.ListItemAllFields);

                    pageLayoutAnalyser.AnalysePageLayout(item);
                    result = pageLayoutAnalyser.GenerateMappingFile();
                }



                Assert.IsTrue(result != string.Empty);
            }
        }