public void CreatePageWithDescription_RenderPage_CheckDescription()
        {
            var testName = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            var pageName = testName + "MvcPage";
            var pageTitle = testName + "Mvc Page";
            var urlName = testName + "mvc-page";
            var description = "customdescription1";
            var descriptionTag = "<meta name=\"description\" content=\"customdescription1\" />";
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

            using (var contentGenerator = new PageContentGenerator())
            {
                var pageId = contentGenerator.CreatePage(pageName, pageTitle, urlName);
                var pageManager = PageManager.GetManager();
                var page = pageManager.GetPageNode(pageId);
                page.Description = description;
                page.GetPageData().Description = description;
                pageManager.SaveChanges();

                string responseContent = WebRequestHelper.GetPageWebContent(url);

                Assert.IsTrue(responseContent.Contains(descriptionTag), "The response content doesn't contain description meta tag.");

                int descriptionTagCount = Regex.Matches(responseContent, Regex.Escape(descriptionTag)).Count;
                Assert.IsFalse(descriptionTagCount == 1, "The response content contains description meta tag more than once.");
            }
        }
        public void StyleSheetWidget_RendersInHead()
        {
            var testName = MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix = testName;
            string pageTitlePrefix = testName;
            string urlNamePrefix = testName;
            string url = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix);

            var mvcProxy = new MvcControllerProxy();
            mvcProxy.ControllerName = typeof(StyleSheetController).FullName;
            var controller = new StyleSheetController();
            controller.Model.Mode = ResourceMode.Reference;
            controller.Model.ResourceUrl = "http://my-styles.com/styles.css";
            controller.Model.MediaType = "screen";
            mvcProxy.Settings = new ControllerSettings(controller);

            using (var generator = new PageContentGenerator())
            {
                var pageId = generator.CreatePage(pageNamePrefix, pageTitlePrefix, urlNamePrefix);
                PageContentGenerator.AddControlToPage(pageId, mvcProxy, "CSS widget");

                string responseContent = PageInvoker.ExecuteWebRequest(url);
                Assert.IsTrue(this.IsInHead(responseContent, @"<link href=""http://my-styles.com/styles.css"" media=""screen"" rel=""stylesheet"" type=""text/css"" />"), "The stylesheet reference was not found in the head.");
            }
        }
예제 #3
0
        public void CreatePageWithDescription_RenderPage_CheckDescription()
        {
            var    testName       = System.Reflection.MethodInfo.GetCurrentMethod().Name;
            var    pageName       = testName + "MvcPage";
            var    pageTitle      = testName + "Mvc Page";
            var    urlName        = testName + "mvc-page";
            var    description    = "customdescription1";
            var    descriptionTag = "<meta name=\"description\" content=\"customdescription1\" />";
            string url            = UrlPath.ResolveAbsoluteUrl("~/" + urlName);

            using (var contentGenerator = new PageContentGenerator())
            {
                var pageId      = contentGenerator.CreatePage(pageName, pageTitle, urlName);
                var pageManager = PageManager.GetManager();
                var page        = pageManager.GetPageNode(pageId);
                page.Description = description;
                page.GetPageData().Description = description;
                pageManager.SaveChanges();

                string responseContent = WebRequestHelper.GetPageWebContent(url);

                var responseContentDescriptionTagsCount = Regex.Matches(responseContent, descriptionTag).Count;
                Assert.IsTrue(responseContentDescriptionTagsCount == 1, "The response content does not contain description meta tag exactly once.");
            }
        }
예제 #4
0
        public void StyleSheetWidget_RendersInHead()
        {
            var    testName        = MethodInfo.GetCurrentMethod().Name;
            string pageNamePrefix  = testName;
            string pageTitlePrefix = testName;
            string urlNamePrefix   = testName;
            string url             = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix);

            var mvcProxy = new MvcControllerProxy();

            mvcProxy.ControllerName = typeof(StyleSheetController).FullName;
            var controller = new StyleSheetController();

            controller.Model.Mode        = ResourceMode.Reference;
            controller.Model.ResourceUrl = "http://my-styles.com/styles.css";
            controller.Model.MediaType   = "screen";
            mvcProxy.Settings            = new ControllerSettings(controller);

            using (var generator = new PageContentGenerator())
            {
                var pageId = generator.CreatePage(pageNamePrefix, pageTitlePrefix, urlNamePrefix);
                PageContentGenerator.AddControlToPage(pageId, mvcProxy, "CSS widget");

                string responseContent = PageInvoker.ExecuteWebRequest(url);
                Assert.IsTrue(this.IsInHead(responseContent, @"<link href=""http://my-styles.com/styles.css"" media=""screen"" rel=""stylesheet"" type=""text/css"" />"), "The stylesheet reference was not found in the head.");
            }
        }