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
.Framework
.Tests
.Wizards
17 using NUnit
.Framework
;
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
;
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
);
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
)