Refactored the Kernel registration fluent interface to be more readable, better suppo...
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Actions / DynamicActionExecutorTestCase.cs
blobc825ea56accce1e90c769df4f6e7ab1f41a08098
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.Tests.Actions
17 using NUnit.Framework;
18 using Castle.MonoRail.Framework.Test;
20 [TestFixture]
21 public class DynamicActionExecutorTestCase
23 [Test]
24 public void DelegatesToDynamicAction()
26 ActionStub dynAction = new ActionStub();
28 DynamicActionExecutor executor = new DynamicActionExecutor(dynAction);
30 MockRequest req = new MockRequest();
31 MockResponse res = new MockResponse();
32 MockServices services = new MockServices();
33 IEngineContext engineContext = new MockEngineContext(req, res, services, new UrlInfo("area", "controller", "action"));
35 object retVal = executor.Execute(engineContext, new DummyController(), new ControllerContext());
36 Assert.IsTrue(dynAction.WasExecuted);
37 Assert.AreEqual(3, retVal);
40 public class ActionStub : IDynamicAction
42 private bool wasExecuted;
44 public object Execute(IEngineContext engineContext, IController controller, IControllerContext controllerContext)
46 wasExecuted = true;
47 return 3;
50 public bool WasExecuted
52 get { return wasExecuted; }
56 public class DummyController : Controller