public string AuditIcon(IAuditable auditable) { DateFormatHelper dateHelper = new DateFormatHelper(); StringBuilder auditInfo = new StringBuilder(); auditInfo.AppendFormat("Created at: {0}\n", dateHelper.ToShortDateTime(auditable.CreatedAt)); auditInfo.AppendFormat("Created by: {0}\n", HtmlEncode(auditable.CreatedBy)); auditInfo.AppendFormat("Updated at: {0}\n", dateHelper.ToShortDateTime(auditable.UpdatedAt)); auditInfo.AppendFormat("Updated by: {0}\n", HtmlEncode(auditable.UpdatedBy)); return string.Format("<img src='/Content/images/audit.png' alt='{0}' />", auditInfo.ToString().Replace("'", "\\'")); }
public virtual void SetUp() { PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase); Helpers = new HelperDictionary(); var services = new StubMonoRailServices { UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()), UrlTokenizer = new DefaultUrlTokenizer() }; var urlInfo = new UrlInfo( "example.org", "test", "/TestBrail", "http", 80, "http://test.example.org/test_area/test_controller/test_action.tdd", Area, ControllerName, Action, "tdd", "no.idea"); StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services, urlInfo); StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder); StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer); ViewComponentFactory = new DefaultViewComponentFactory(); ViewComponentFactory.Service(StubEngineContext); ViewComponentFactory.Initialize(); StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory); ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag }; StubEngineContext.CurrentControllerContext = ControllerContext; Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext); Helpers["formhelper"] = Helpers["form"] = new FormHelper(StubEngineContext); Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext); Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext); var loader = new FileAssemblyViewSourceLoader("Views"); _monoRailViewEngine = new NHamlMonoRailViewEngine(); _monoRailViewEngine.TemplateEngine.Options.TemplateCompiler = new CSharp3TemplateCompiler(); _monoRailViewEngine.SetViewSourceLoader(loader); _templateEngine = _monoRailViewEngine.TemplateEngine; _templateEngine.Options.TemplateBaseType = typeof( NHamlMonoRailView ); ViewComponentFactory.Inspect(GetType().Assembly); }
public void SetUp() { Layout = null; PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase); Helpers = new HelperDictionary(); StubMonoRailServices services = new StubMonoRailServices(); services.UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()); services.UrlTokenizer = new DefaultUrlTokenizer(); UrlInfo urlInfo = new UrlInfo( "example.org", "test", "/TestBrail", "http", 80, "http://test.example.org/test_area/test_controller/test_action.tdd", Area, ControllerName, Action, "tdd", "no.idea"); StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services, urlInfo); StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder); StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer); ViewComponentFactory = new DefaultViewComponentFactory(); ViewComponentFactory.Service(StubEngineContext); ViewComponentFactory.Initialize(); StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory); ControllerContext = new ControllerContext(); ControllerContext.Helpers = Helpers; ControllerContext.PropertyBag = PropertyBag; StubEngineContext.CurrentControllerContext = ControllerContext; Helpers["formhelper"] = Helpers["form"] = new FormHelper(StubEngineContext); Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext); Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext); Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext); string viewPath = Path.Combine(viewSourcePath, "Views"); FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath); loader.AddAssemblySource( new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName, "Castle.MonoRail.Views.Brail.Tests.ResourcedViews")); BooViewEngine = new BooViewEngine(); BooViewEngine.Options = new BooViewEngineOptions(); BooViewEngine.Options.SaveDirectory = Environment.CurrentDirectory; BooViewEngine.Options.SaveToDisk = false; BooViewEngine.Options.Debug = true; BooViewEngine.Options.BatchCompile = false; BooViewEngine.SetViewSourceLoader(loader); BooViewEngine.Initialize(); BeforEachTest(); }