Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Wizards / WizardActionProviderTestCase.cs
blobe84b1ed62bd83a0ddc2422a1f8d842bfdf172cc8
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.Wizards
17 using NUnit.Framework;
18 using Test;
20 [TestFixture]
21 public class WizardActionProviderTestCase
23 private MockEngineContext engineContext;
24 private ViewEngineManagerStub viewEngStub;
25 private MockServices services;
26 private MockRequest request;
27 private MockResponse response;
28 private WizardActionProvider actionProvider;
30 [SetUp]
31 public void Init()
33 request = new MockRequest();
34 response = new MockResponse();
35 services = new MockServices();
36 viewEngStub = new ViewEngineManagerStub();
37 services.ViewEngineManager = viewEngStub;
38 engineContext = new MockEngineContext(request, response, services, null);
39 actionProvider = new WizardActionProvider();
42 [Test, ExpectedException(typeof(MonoRailException), "The controller home must implement the interface IWizardController to be used as a wizard")]
43 public void RejectsControllerThatDoesNotImplementIWizardController()
45 NotAWizardController controller = new NotAWizardController();
47 IControllerContext context = services.ControllerContextFactory.
48 Create("", "home", "index", services.ControllerDescriptorProvider.BuildDescriptor(controller));
50 actionProvider.IncludeActions(engineContext, controller, context);
53 [Test, ExpectedException(typeof(MonoRailException), "The controller home returned no WizardStepPage")]
54 public void ThrowsExceptionIfNoStepsAreReturned()
56 WizardWithNoSteps controller = new WizardWithNoSteps();
58 IControllerContext context = services.ControllerContextFactory.
59 Create("", "home", "index", services.ControllerDescriptorProvider.BuildDescriptor(controller));
61 actionProvider.IncludeActions(engineContext, controller, context);
64 #region Controllers
66 class NotAWizardController : Controller
70 class WizardWithNoSteps : Controller, IWizardController
72 public void OnWizardStart()
74 throw new System.NotImplementedException();
77 public bool OnBeforeStep(string wizardName, string stepName, IWizardStepPage step)
79 throw new System.NotImplementedException();
82 public void OnAfterStep(string wizardName, string stepName, IWizardStepPage step)
84 throw new System.NotImplementedException();
87 public IWizardStepPage[] GetSteps(IEngineContext context)
89 return null;
93 #endregion