1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
.Tests
17 using Castle
.MonoRail
.Test
;
18 using NUnit
.Framework
;
20 [TestFixture
, Category(TestCategories
.Core
)]
21 public class ControllerExecutorTestCase
23 private SimpleController controller
;
24 private IExecutionContext testContext
;
27 public void CreateObjects()
29 controller
= new SimpleController();
30 testContext
= new TestContext(new UrlInfo("area", "controller", "index"));
34 public void ControllerStateIsProperlyInitialized()
36 new ControllerExecutor(controller
, testContext
);
38 Assert
.AreEqual("area", controller
.AreaName
);
39 Assert
.AreEqual("controller", controller
.Name
);
40 Assert
.AreEqual("index", controller
.ActionName
);
44 public void ActionIsSelectedBasedOnUrlActionPiece()
46 ControllerExecutor executor
= new ControllerExecutor(controller
, testContext
);
48 ActionExecutor actionExec
= executor
.SelectAction();
50 Assert
.IsNotNull(actionExec
);
51 Assert
.AreEqual(ActionType
.Method
, actionExec
.ActionType
);
52 Assert
.AreEqual("Index", actionExec
.Name
);
56 public void ActionIsExecuted()
58 ControllerExecutor executor
= new ControllerExecutor(controller
, testContext
);
60 executor
.Execute(executor
.SelectAction());
62 Assert
.IsTrue(controller
.wasRun
, "ControllerExecutor failed to execute the action");
65 public class SimpleController
: Controller