public virtual void Init() { mocks = new MockRepository(); var services = new StubMonoRailServices(); services.ViewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); viewComponentFactory = new DefaultViewComponentFactory(); viewComponentFactory.Initialize(); services.AddService(typeof(IViewComponentFactory), viewComponentFactory); services.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); var settings = new SparkSettings(); engine = new SparkViewEngine(settings); services.AddService(typeof(ISparkViewEngine), engine); factory = new SparkViewFactory(); factory.Service(services); controller = MockRepository.GenerateMock<IController>(); controllerContext = new ControllerContext(); var request = new StubRequest(); request.FilePath = ""; var response = new StubResponse(); engineContext = new StubEngineContext(request, response, new UrlInfo("", "Home", "Index", "/", "castle")); engineContext.AddService(typeof(IViewComponentFactory), viewComponentFactory); engineContext.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); }
public void Init() { selector = new DefaultActionSelector(); var request = new StubRequest(); var response = new StubResponse(); var services = new StubMonoRailServices(); engine = new StubEngineContext(request, response, services, new UrlInfo("area", "controller", "action1")); }
protected override IMockResponse BuildResponse(UrlInfo info) { StubResponse response = new StubResponse(info, new DefaultUrlBuilder(), new StubServerUtility(), new RouteMatch(), Referrer); return response; }
public void Init() { var request = new StubRequest(); var response = new StubResponse(); services = new StubMonoRailServices(); engStubViewEngineManager = new StubViewEngineManager(); services.ViewEngineManager = engStubViewEngineManager; filterFactoryMock = mockRepository.DynamicMock<IFilterFactory>(); services.FilterFactory = filterFactoryMock; engineContext = new StubEngineContext(request, response, services, null); }
public void DelegatesToDynamicAction() { var dynAction = new ActionStub(); var executor = new DynamicActionExecutor(dynAction); var req = new StubRequest(); var res = new StubResponse(); var services = new StubMonoRailServices(); IEngineContext engineContext = new StubEngineContext(req, res, services, new UrlInfo("area", "controller", "action")); var retVal = executor.Execute(engineContext, new DummyController(), new ControllerContext()); Assert.IsTrue(dynAction.WasExecuted); Assert.AreEqual(3, retVal); }
public void CompatibleExecutorDelegatesInvocationToControllerUsingDelegate() { var controller = new BaseController(); var actionMeta = new ActionMetaDescriptor(); ActionMethodExecutorCompatible.InvokeOnController delegateToController = controller.InvokeMethodStub; var executor = new ActionMethodExecutorCompatible(GetActionMethod(controller), actionMeta, delegateToController); var req = new StubRequest(); var res = new StubResponse(); var services = new StubMonoRailServices(); IEngineContext engineContext = new StubEngineContext(req, res, services, new UrlInfo("area", "controller", "action")); var retVal = executor.Execute(engineContext, controller, new ControllerContext()); Assert.IsTrue(controller.WasExecuted); Assert.AreEqual(2, retVal); }
public virtual void Setup() { _mocks = new MockRepository(); _services = _mocks.DynamicMock<ICodeGeneratorServices>(); _response = new StubResponse(); UrlInfo url = new UrlInfo("eleutian.com", "www", _virtualDirectory, "http", 80, Path.Combine(Path.Combine("Area", "Controller"), "Action"), "Area", "Controller", "Action", "rails", ""); _railsContext = new StubEngineContext(new StubRequest(), _response, new StubMonoRailServices(), url); ((StubEngineContext)_railsContext).Server = _mocks.DynamicMock<IServerUtility>(); _serverUtility = _railsContext.Server; _argumentConversionService = _mocks.DynamicMock<IArgumentConversionService>(); _controller = new TestController(); }
public void ExecutesActionAndReturnValue() { BaseController controller = new BaseController(); ActionMetaDescriptor actionMeta = new ActionMetaDescriptor(); ActionMethodExecutor executor = new ActionMethodExecutor(GetActionMethod(controller), actionMeta); StubRequest req = new StubRequest(); StubResponse res = new StubResponse(); StubMonoRailServices services = new StubMonoRailServices(); IEngineContext engineContext = new StubEngineContext(req, res, services, new UrlInfo("area", "controller", "action")); object retVal = executor.Execute(engineContext, controller, new ControllerContext()); Assert.IsTrue(controller.WasExecuted); Assert.AreEqual(1, retVal); }