public void SetUp() { _output = new StringWriter(); _mocks = new MockRepository(); _httpContext = _mocks.DynamicMock <HttpContextBase>(); //new TestHttpContext(); var response = _mocks.DynamicMock <HttpResponseBase>(); SetupResult.For(response.Output).Return(_output); SetupResult.For(_httpContext.Request).Return(_mocks.DynamicMock <HttpRequestBase>()); SetupResult.For(_httpContext.Response).Return(response); // SetupResult.For(_httpContext.Session).Return(_mocks.DynamicMock<HttpSessionStateBase>()); var requestContext = new RequestContext(_httpContext, new RouteData()); _controller = _mocks.StrictMock <Controller>(); _mocks.Replay(_controller); controllerContext = new ControllerContext(requestContext, _controller); // _viewContext = new ViewContext(controllerContext, null, new ViewDataDictionary(), null); _viewEngine = new BooViewEngine { ViewSourceLoader = new FileSystemViewSourceLoader(VIEW_ROOT_DIRECTORY), Options = new BooViewEngineOptions() }; _viewEngine.Initialize(); _mocks.Replay(_httpContext); }
public BrailViewFactory(BooViewEngine viewEngine) { if (viewEngine == null) { throw new ArgumentNullException("viewEngine"); } _viewEngine = viewEngine; }
public void CanRenderViewWithoutUsingFullMonoRailPipeline() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DummyController controller = new DummyController(); PrepareController(controller, "", "home", "index"); bve.Process(sw, Context, controller, "home/index"); Assert.AreEqual("Brail is wonderful", sw.ToString()); }
public void CanOutputParagraphWithClassAttribute() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); PrepareController(controller, "", "dsl", "attributeOutput"); bve.Process(sw, Context, controller, "dsl/attributeOutput"); Assert.AreEqual("<html><p class=\"foo\">hello world</p></html>", sw.ToString()); }
public void RegisterHtmlAllowsCallToHtml() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); PrepareController(controller, "", "dsl", "registerHtml"); bve.Process(sw, Context, controller, "dsl/registerHtml"); Assert.AreEqual(@"<html>hello world</html>", sw.ToString()); }
public void ParametersCanBeReferencedByView() { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DslController controller = new DslController(); controller.PropertyBag["SayHelloTo"] = "Harris"; PrepareController(controller, "", "dsl", "expandParameters"); bve.Process(sw, Context, controller, "dsl/expandParameters"); Assert.AreEqual("<html><p>hello, Harris</p></html>", sw.ToString()); }
private ViewEngineBase GetBrailEngine() { var engine = new BooViewEngine(); engine.Options = new BooViewEngineOptions(); engine.Options.SaveDirectory = Environment.CurrentDirectory; engine.Options.SaveToDisk = false; engine.Options.Debug = true; engine.Options.BatchCompile = false; engine.SetViewSourceLoader(_viewSourceLoader); engine.Initialize(); return(engine); }
protected string ProcessView(IDictionary dictionary, string templatePath) { BooViewEngine bve = new BooViewEngine(); string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); bve.Initialize(); StringWriter sw = new StringWriter(); DummyController controller = new DummyController(); controller.PropertyBag = dictionary; PrepareController(controller, "", "home", "index"); bve.Process(sw, Context, controller, templatePath); return sw.ToString(); }
public void SetUp() { _mocks = new MockRepository(); var httpContext = new TestHttpContext(); var requestContext = new RequestContext(httpContext, new RouteData()); var controller = _mocks.StrictMock <ControllerBase>(); _mocks.Replay(controller); var viewEngine = new BooViewEngine { ViewSourceLoader = new FileSystemViewSourceLoader(VIEW_ROOT_DIRECTORY), Options = new BooViewEngineOptions() }; viewEngine.Initialize(); _viewEngine = new BrailViewFactory(viewEngine); _mocks.ReplayAll(); }
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(); }
public void SetUp() { Layout = null; 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); StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory); ControllerContext = new ControllerContext { Helpers = Helpers, 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); var viewPath = Path.Combine(viewSourcePath, "Views"); var loader = new FileAssemblyViewSourceLoader(viewPath); loader.AddAssemblySource( new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName, "Castle.MonoRail.Views.Brail.Tests.ResourcedViews")); BooViewEngine = new BooViewEngine { Options = new BooViewEngineOptions { SaveDirectory = Environment.CurrentDirectory, SaveToDisk = false, Debug = true, BatchCompile = false } }; BooViewEngine.SetViewSourceLoader(loader); BooViewEngine.Initialize(); BeforEachTest(); }
public DummySubView(BooViewEngine viewEngine, TextWriter output, IEngineContext context, Controller controller, IControllerContext controllerContext) : base(viewEngine, output, context, controller, controllerContext) { }
protected TestBrailBase(BooViewEngine viewEngine) : base(viewEngine) { }
public void SetUp() { _mocks = new MockRepository(); _viewEngine = _mocks.DynamicMock <BooViewEngine>(); _view = _mocks.StrictMock <BrailBase>(_viewEngine); }