コード例 #1
0
        public void TemplateHierarchy_RequestPage_ShouldLogExecutions()
        {
            Guid templateId1 = default(Guid);
            Guid templateId2 = default(Guid);

            PageNode pageNode = null;

            try
            {
                pageNode = this.CreatePageTemplateHierarchy(ref templateId1, ref templateId2);

                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                // Request page
                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(3);
            }
            finally
            {
                this.DeletePages(pageNode);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId2);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId1);
            }
        }
        public void DynamicWidget_RequestPage_ShouldLogRazorViewCompilation()
        {
            var widgetText       = "</asp:PlaceHolder>";
            var addedText        = "Some added text.";
            var widgetTextEdited = string.Concat(widgetText, addedText);

            PageNode pageNode = null;

            try
            {
                pageNode = this.CreateBootstrapPageWithDynamicWidget();

                this.EditDynamicContentWidgetMasterTemplate(widgetText, widgetTextEdited);

                var url = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());
                this.ExecuteAuthenticatedRequest(url);
                this.FlushData();

                // Assert widget performance
                int widgetCount = 1;
                this.AssertWidgetExecutionCount(widgetCount);
                this.AssertViewCompilationCount(widgetCount);
            }
            finally
            {
                this.EditDynamicContentWidgetMasterTemplate(widgetTextEdited, widgetText);
                this.DeletePages(pageNode);
            }
        }
コード例 #3
0
        public void TemplateHierarchy_EditWidget_ShouldLogCompilation()
        {
            Guid templateId1 = default(Guid);
            Guid templateId2 = default(Guid);

            var    widgetName         = "News";
            var    widgetTemplateName = "List.NewsList.cshtml";
            var    widgetText         = @"<ul class=""list-unstyled"">";
            var    widgetTextEdited   = @"<ul class=""list-unstyled"">edited";
            string widgetFilePath     = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(ResourcePackages.Bootstrap, widgetName, widgetTemplateName);

            PageNode pageNode = null;

            try
            {
                pageNode = this.CreatePageTemplateHierarchy(ref templateId1, ref templateId2);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                var viewPath     = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend.News/Mvc/Views/News/List.NewsList.cshtml";
                var fullViewPath = string.Concat(viewPath, "#Bootstrap.cshtml");

                // Request page
                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.ClearData();
                FeatherServerOperations.ResourcePackages().EditLayoutFile(widgetFilePath, widgetText, widgetTextEdited);
                this.WaitForAspNetCacheToBeInvalidated(fullViewPath);

                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(3);
                this.AssertViewCompilationCount(1);

                var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl);

                var widgetCompilationText = "Compile view \"List.NewsList.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(NewsController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(3);
                this.AssertViewCompilationCount(0);
            }
            finally
            {
                FeatherServerOperations.ResourcePackages().EditLayoutFile(widgetFilePath, widgetTextEdited, widgetText);
                this.DeletePages(pageNode);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId2);
                Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().DeletePageTemplate(templateId1);
            }
        }
        //// StoryId: 208381
        public void DynamicWidgetMvc_RequestPage_ShouldLogRazorViewCompilation()
        {
            var text     = "Expected text";
            var viewName = "List.Press Article.cshtml";
            var basePath = HostingEnvironment.MapPath("~/");

            var widgetViewsPath = Path.Combine(basePath, "Mvc\\Views\\PressArticle");

            if (!Directory.Exists(widgetViewsPath))
            {
                Directory.CreateDirectory(widgetViewsPath);
            }

            var listViewPath = Path.Combine(widgetViewsPath, viewName);

            PageNode pageNode = null;

            try
            {
                pageNode = this.CreateBootstrapPageWithDynamicWidget();

                var url = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());
                this.ExecuteAuthenticatedRequest(url);
                this.FlushData();
                this.ClearData();

                File.WriteAllText(listViewPath, text);

                var content = this.ExecuteAuthenticatedRequest(url);
                this.FlushData();

                // Assert widget performance
                Assert.Contains(content, text, StringComparison.Ordinal);

                int widgetCount = 1;
                this.AssertWidgetExecutionCount(widgetCount);
                this.AssertViewCompilationCount(widgetCount);
            }
            finally
            {
                this.DeletePages(pageNode);

                if (Directory.Exists(widgetViewsPath))
                {
                    Directory.Delete(widgetViewsPath, true);
                }
            }
        }
コード例 #5
0
        ////StoryId: 208384
        public void EditLayoutRoot_RequestPageBasedOnTemplate_ShouldLogCompilation()
        {
            PageNode pageNode         = null;
            var      layoutText       = @"@Html.SfPlaceHolder(""TestPlaceHolder"")	";
            var      layoutTextEdited = @"edited @Html.SfPlaceHolder(""TestPlaceHolder"") ";

            try
            {
                this.CreateLayoutFile(TestTemplateFileName);
                pageNode = this.CreatePageWithMvcWidget(TestTemplateTitle, TestPlaceholder);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                var viewPath       = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Layouts/TestLayout.cshtml";
                var layoutFilePath = Path.Combine(HostingEnvironment.MapPath(LayoutsFolderRelativePath), TestTemplateFileName);
                FeatherServerOperations.ResourcePackages().EditLayoutFile(layoutFilePath, layoutText, layoutTextEdited);
                this.WaitForAspNetCacheToBeInvalidated(viewPath);

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                // Assert data
                this.AssertWidgetExecutionCount(1);
                this.AssertViewCompilationCount(1);

                var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl);

                var widgetCompilationText = "Compile view \"TestLayout.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(GenericController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(1);
                this.AssertViewCompilationCount(0);
            }
            finally
            {
                this.DeletePages(pageNode);
                ServerOperations.Templates().DeletePageTemplate(TestTemplateTitle);
                this.DeleteLayoutFile(TestTemplateFileName);
            }
        }
コード例 #6
0
        ////StoryId: 208384
        public void TemplateBasedOnNewLayout_RequestPage_ShouldLogRazorViewCompilation()
        {
            string   childTemplateTitle = "NewTestLayout";
            PageNode pageNode           = null;

            try
            {
                this.CreateLayoutFile(TestTemplateFileName);
                this.CreatePureMvcPageTemplate(childTemplateTitle, TestTemplateTitle);

                pageNode = this.CreatePageWithMvcWidget(childTemplateTitle, TestPlaceholder);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                var viewPath = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Layouts/TestLayout.cshtml";

                // Assert data
                this.AssertWidgetExecutionCount(1);
                this.AssertViewCompilationCount(1);

                var rootOperationId       = this.GetRequestLogRootOperationId(fullPageUrl);
                var widgetCompilationText = "Compile view \"TestLayout.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(GenericController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);

                this.ClearData();
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(1);
                this.AssertViewCompilationCount(0);
            }
            finally
            {
                this.DeletePages(pageNode);

                ServerOperations.Templates().DeletePageTemplate(childTemplateTitle);
                ServerOperations.Templates().DeletePageTemplate(TestTemplateTitle);

                this.DeleteLayoutFile(TestTemplateFileName);
            }
        }
コード例 #7
0
        ////StoryId: 208384
        public void EditLayout_RequestPageBasedOnTemplate_ShouldLogCompilation()
        {
            var      templateTitle        = "Bootstrap.default";
            var      bootstrapPlaceholder = "Contentplaceholder1";
            var      layoutName           = "Bootstrap.default.cshtml";
            var      layoutText           = @"@Html.SfPlaceHolder(""Contentplaceholder1"")	";
            var      layoutTextEdited     = @"edited @Html.SfPlaceHolder(""Contentplaceholder1"") ";
            string   filePath             = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(Bootstrap, "Layouts", layoutName);
            PageNode pageNode             = null;

            try
            {
                pageNode = this.CreatePageWithMvcWidget(templateTitle, bootstrapPlaceholder);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();
                this.ClearData();

                var viewPath = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Layouts/Bootstrap.default.cshtml";
                FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, layoutText, layoutTextEdited);
                this.WaitForAspNetCacheToBeInvalidated(viewPath);

                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                // Assert data
                this.AssertWidgetExecutionCount(1);
                this.AssertViewCompilationCount(1);

                var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl);

                var widgetCompilationText = "Compile view \"Bootstrap.default.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(GenericController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);
            }
            finally
            {
                FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, layoutTextEdited, layoutText);
                this.DeletePages(pageNode);
                this.ClearData();
            }
        }
コード例 #8
0
        public static string GetPageUrl(string pageId)
        {
            string pageUrl = String.Empty;

            PageManager pageManager = PageManager.GetManager();

            if (pageManager != null)
            {
                if (!pageId.IsNullOrEmpty())
                {
                    Guid     pageNodeId = new Guid(pageId);
                    PageNode pageNode   = pageManager.GetPageNodes().Where(n => n.Id == pageNodeId).FirstOrDefault();
                    // We will get the url as ~/homepage
                    // So removing the first character
                    if (pageNode != null)
                    {
                        pageUrl = pageNode.GetUrl().Substring(1);
                    }

                    SiteSettingsHelper siteSettingsHelper = new SiteSettingsHelper();
                    var cultureIsEnabled = siteSettingsHelper.GetCurrentSiteCultureIsEnabled();

                    if (bool.TryParse(cultureIsEnabled, out bool output))
                    {
                        if (bool.Parse(cultureIsEnabled))
                        {
                            var targetCulture = Thread.CurrentThread.CurrentUICulture;
                            var culture       = CultureInfo.GetCultureInfo(targetCulture.Name);
                            pageUrl = "/" + culture.Name + pageUrl;
                        }
                    }
                }
            }

            return(pageUrl);
        }
コード例 #9
0
        public void ModifiedView_RequestPage_ShouldLogCompilation()
        {
            string viewFileName = "Default.cshtml";
            string widgetName   = "ContentBlock";

            var    widgetText       = @"@Html.Raw(Model.Content)";
            var    widgetTextEdited = @"edited @Html.Raw(Model.Content)";
            string filePath         = FeatherServerOperations.ResourcePackages().GetResourcePackageMvcViewDestinationFilePath(ResourcePackages.Bootstrap, widgetName, viewFileName);

            PageNode pageNode = null;

            try
            {
                Guid templateId  = Telerik.Sitefinity.TestUtilities.CommonOperations.ServerOperations.Templates().GetTemplateIdByTitle(PageTemplateName);
                var  pageId      = ServerOperations.Pages().CreatePage("TestPage1", templateId);
                var  pageNodeId  = ServerOperations.Pages().GetPageNodeId(pageId);
                var  pageManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
                pageNode = pageManager.GetPageNode(pageNodeId);
                var fullPageUrl = RouteHelper.GetAbsoluteUrl(pageNode.GetUrl());

                int widgetCount = 3;
                for (var i = 0; i < widgetCount; i++)
                {
                    ServerOperationsFeather.Pages().AddContentBlockWidgetToPage(pageNodeId, "ContentBlock", "Contentplaceholder1");
                }

                var viewPath     = "~/Frontend-Assembly/Telerik.Sitefinity.Frontend.ContentBlock/Mvc/Views/ContentBlock/Default.cshtml";
                var fullViewPath = string.Concat(viewPath, "#Bootstrap.cshtml");

                FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, widgetText, widgetTextEdited);
                this.WaitForAspNetCacheToBeInvalidated(fullViewPath);

                // Request page
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                this.AssertWidgetExecutionCount(widgetCount);
                this.AssertViewCompilationCount(1);

                // Assert data
                var rootOperationId = this.GetRequestLogRootOperationId(fullPageUrl);

                var widgetCompilationText = "Compile view \"Default.cshtml#Bootstrap.cshtml\" of controller \"" + typeof(ContentBlockController).FullName + "\"";
                this.AssertViewCompilationParams(rootOperationId, viewPath, widgetCompilationText);

                this.ClearData();

                // Request page again
                this.ExecuteAuthenticatedRequest(fullPageUrl);
                this.FlushData();

                // Assert new data
                this.AssertWidgetExecutionCount(widgetCount);
                this.AssertViewCompilationCount(0);
            }
            finally
            {
                FeatherServerOperations.ResourcePackages().EditLayoutFile(filePath, widgetTextEdited, widgetText);
                this.DeletePages(pageNode);
            }
        }
コード例 #10
0
        /// <summary>
        /// Gets the page URL by page node.
        /// </summary>
        /// <param name="pageNode">The page node.</param>
        /// <returns></returns>
        public static string GetPageUrlByPageNode(PageNode pageNode)
        {
            string url = pageNode.GetUrl();

            return(url);
        }