Пример #1
0
 public void Adds_description_meta_tag()
 {
     var html = XDocument.Parse("<html><head><title>Test</title></head><body></body></html>");
     var pageview = new PageView(html, s => null, Enumerable.Empty<IPageViewModifier>());
     var sb = new StringBuilder();
     using (var writer = new StringWriter(sb))
     {
         var viewContext = FakeViewContext(pageview);
         viewContext.ViewData["page"] = new Page(new FakePageContainer(), "", "", "", false, "test");
         pageview.Render(viewContext, writer);
     }
     Assert.Contains("<meta name=\"description\" content=\"test\" />", sb.ToString());
 }
Пример #2
0
        public void Adds_description_meta_tag()
        {
            var html     = XDocument.Parse("<html><head><title>Test</title></head><body></body></html>");
            var pageview = new PageView(html, s => null, Enumerable.Empty <IPageViewModifier>());
            var sb       = new StringBuilder();

            using (var writer = new StringWriter(sb))
            {
                var viewContext = FakeViewContext(pageview);
                viewContext.ViewData["page"] = new Page(new FakePageContainer(), "", "", "", false, "test");
                pageview.Render(viewContext, writer);
            }
            Assert.Contains("<meta name=\"description\" content=\"test\" />", sb.ToString());
        }
Пример #3
0
 static ViewContext FakeViewContext(PageView pageview)
 {
     return new ViewContext(
         new ControllerContext(
             new RequestContext(
                 new FakeHttpContext(),
                 new RouteData()
             ),
             new FakeController()
         ),
         pageview,
         new ViewDataDictionary(),
         new TempDataDictionary()
     );
 }
Пример #4
0
 static ViewContext FakeViewContext(PageView pageview)
 {
     return(new ViewContext(
                new ControllerContext(
                    new RequestContext(
                        new FakeHttpContext(),
                        new RouteData()
                        ),
                    new FakeController()
                    ),
                pageview,
                new ViewDataDictionary(),
                new TempDataDictionary()
                ));
 }
Пример #5
0
 PageView CreateAndCachePageView(ControllerContext controllerContext, string viewName, string templateFilename)
 {
     var html = XDocument.Load(templateFilename);
     if (html.Root.Name.LocalName == "use-master")
     {
         var masterFilename = Path.Combine(websiteConfiguration.TemplateDirectory, html.Root.Attribute("id").Value);
         var pageView = CreatePageViewWithMaster(html, masterFilename);
         controllerContext.HttpContext.Cache.Insert(viewName, pageView, new CacheDependency(new[] { masterFilename, templateFilename }));
         return pageView;
     }
     else
     {
         var pageView = new PageView(html, getPlugin, modifiers);
         controllerContext.HttpContext.Cache.Insert(viewName, pageView, new CacheDependency(templateFilename));
         return pageView;
     }
 }
Пример #6
0
        PageView CreateAndCachePageView(ControllerContext controllerContext, string viewName, string templateFilename)
        {
            var html = XDocument.Load(templateFilename);

            if (html.Root.Name.LocalName == "use-master")
            {
                var masterFilename = Path.Combine(websiteConfiguration.TemplateDirectory, html.Root.Attribute("id").Value);
                var pageView       = CreatePageViewWithMaster(html, masterFilename);
                controllerContext.HttpContext.Cache.Insert(viewName, pageView, new CacheDependency(new[] { masterFilename, templateFilename }));
                return(pageView);
            }
            else
            {
                var pageView = new PageView(html, getPlugin, modifiers);
                controllerContext.HttpContext.Cache.Insert(viewName, pageView, new CacheDependency(templateFilename));
                return(pageView);
            }
        }