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()); }
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()); }
static ViewContext FakeViewContext(PageView pageview) { return new ViewContext( new ControllerContext( new RequestContext( new FakeHttpContext(), new RouteData() ), new FakeController() ), pageview, new ViewDataDictionary(), new TempDataDictionary() ); }
static ViewContext FakeViewContext(PageView pageview) { return(new ViewContext( new ControllerContext( new RequestContext( new FakeHttpContext(), new RouteData() ), new FakeController() ), pageview, new ViewDataDictionary(), new TempDataDictionary() )); }
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; } }
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); } }