From ee5c988981560d6d30b91af9d7d434f61fe13097 Mon Sep 17 00:00:00 2001 From: hammett Date: Tue, 11 Mar 2008 15:02:06 +0000 Subject: [PATCH] Simplified contextualization of a mock implementation git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4880 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- MonoRail/Castle.MonoRail.Framework/Controller.cs | 16 ++++++----- .../Test/MockEngineContext.cs | 32 ++++++++++++++++++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/MonoRail/Castle.MonoRail.Framework/Controller.cs b/MonoRail/Castle.MonoRail.Framework/Controller.cs index 3a669ed93..5d823c581 100644 --- a/MonoRail/Castle.MonoRail.Framework/Controller.cs +++ b/MonoRail/Castle.MonoRail.Framework/Controller.cs @@ -76,13 +76,6 @@ namespace Castle.MonoRail.Framework { this.context = context; SetEngineContext(engineContext); - ResolveLayout(); - CreateAndInitializeHelpers(); - CreateFiltersDescriptors(); - ProcessScaffoldIfAvailable(); - ActionProviderUtil.RegisterActions(engineContext, this, context); - renderingSupport = new RenderingSupport(context, engineContext); - Initialize(); isContextualized = true; } @@ -104,6 +97,15 @@ namespace Castle.MonoRail.Framework { Contextualize(engineContext, context); } + + ResolveLayout(); + CreateAndInitializeHelpers(); + CreateFiltersDescriptors(); + ProcessScaffoldIfAvailable(); + ActionProviderUtil.RegisterActions(engineContext, this, context); + renderingSupport = new RenderingSupport(context, engineContext); + Initialize(); + RunActionAndRenderView(); } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs index 9bdcd92ae..5a0749bc4 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockEngineContext.cs @@ -28,11 +28,11 @@ namespace Castle.MonoRail.Framework.Test /// public class MockEngineContext : AbstractServiceContainer, IEngineContext { - private readonly IMockRequest request; - private readonly IMockResponse response; private readonly IDictionary contextItems = new HybridDictionary(true); private readonly List renderedEmailTemplates = new List(); private readonly List messagesSent = new List(); + private IMockRequest request; + private IMockResponse response; private IServerUtility serverUtility = new MockServerUtility(); private IPrincipal currentUser; private IDictionary session = new HybridDictionary(true); @@ -47,6 +47,14 @@ namespace Castle.MonoRail.Framework.Test /// /// Initializes a new instance of the class. /// + public MockEngineContext() + : this(new MockRequest(), new MockResponse(), new MockServices(), new UrlInfo("area", "home", "index")) + { + } + + /// + /// Initializes a new instance of the class. + /// /// The request. /// The response. /// The services. @@ -66,6 +74,26 @@ namespace Castle.MonoRail.Framework.Test } /// + /// Gets or sets the mock request. + /// + /// The mock request. + public IMockRequest MockRequest + { + get { return request; } + set { request = value; } + } + + /// + /// Gets or sets the mock response. + /// + /// The mock response. + public IMockResponse MockResponse + { + get { return response; } + set { response = value; } + } + + /// /// Gets the underlying context of the API being used. /// /// -- 2.11.4.GIT