1 // Copyright 2004-2007 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
.Views
.NVelocity
.Tests
17 using Castle
.MonoRail
.Framework
.Tests
;
18 using NUnit
.Framework
;
21 public class WizardSupportTestCase
: AbstractTestCase
24 public void StartRedirectsToFirstPage()
26 DoGet("testwizard/start.rails");
27 AssertRedirectedTo("/testwizard/Page1.rails");
31 public void UnrelatedWizardActionInvocation()
33 DoGet("testwizard/index.rails");
34 AssertReplyEqualTo("Hello!");
38 public void Page1HasCorrectIndex()
40 DoGet("testwizard/Page1.rails");
42 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 0);
43 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page1");
45 // Yes, we invoke it twice
47 DoGet("testwizard/Page1.rails");
49 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 0);
50 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page1");
52 DoGet("testwizard/Page2.rails");
54 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 1);
55 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page2");
59 public void InnerActionsWithNoView()
61 DoGet("testwizard/Page1.rails");
62 AssertFlashDoesNotContain("InnerActionInvoked");
65 // Yes, we invoke it twice
67 DoGet("testwizard/Page1.rails");
69 AssertFlashDoesNotContain("InnerActionInvoked");
71 DoGet("testwizard/Page1-InnerAction.rails");
73 AssertFlashContains("InnerActionInvoked");
77 public void NavigateToURI()
79 DoGet("testwizard/Page4-InnerAction.rails", "navigate.to=uri:testwizard/Page3.rails" );
80 AssertRedirectedTo("/testwizard/testwizard/Page3.rails");
81 AssertFlashContains("InnerActionInvoked");
83 DoGet("testwizard/Page4-InnerAction.rails", "navigate.to=uri:/testwizard/Page3.rails" );
84 AssertRedirectedTo("/testwizard/Page3.rails");
85 AssertFlashContains("InnerActionInvoked");
87 DoGet("testwizard/Page4-InnerAction.rails", "navigate.to=uri:http://google/" );
88 AssertRedirectedTo("http://google/");
89 AssertFlashContains("InnerActionInvoked");
93 public void InnerActionsWithView()
95 DoGet("testwizard/Page1-InnerAction2.rails");
97 AssertReplyEqualTo("View for Inner action 2");
101 public void WizardPageWithView()
103 DoGet("testwizard/Page3.rails");
105 AssertReplyEqualTo("Wizard page 3");
109 public void WizardHelper_HasNextAndPreviousSteps()
111 DoGet("testwizard/Page4.rails");
113 AssertReplyEqualTo("hasprevious True\r\nhasnext False");
117 public void ConditionalWizardSteps()
119 DoGet("testwizardconditions/index.rails");
121 AssertReplyEqualTo("Hello!");
123 DoGet("testwizardconditions/page1.rails");
124 AssertRedirectedTo("/TestWizardConditions/Index.rails");
126 DoGet("testwizardconditions/page1-InnerAction.rails");
127 AssertRedirectedTo("/TestWizardConditions/Index.rails");
129 DoGet("testwizardconditions/page1-InnerAction2.rails");
130 AssertRedirectedTo("/TestWizardConditions/Index.rails");
132 DoGet("testwizardconditions/page1.rails", "id=1");
134 AssertReplyEqualTo("Wizard page 1");
136 DoGet("testwizardconditions/page1-InnerAction.rails", "id=1");
138 AssertReplyEqualTo("InnerAction contents");
140 DoGet("testwizardconditions/page1-InnerAction2.rails", "id=1");
142 AssertReplyEqualTo("View for Inner action 2");
146 public void WizardWithinAnArea()
148 DoGet("wizard/TestWizardWithArea/start.rails");
149 AssertRedirectedTo("/wizard/TestWizardWithArea/Page1.rails");
151 DoGet("wizard/TestWizardWithArea/index.rails");
152 AssertReplyEqualTo("Hello!");
154 DoGet("wizard/TestWizardWithArea/Page1.rails");
156 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstepindex", 0);
157 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstep", "Page1");
159 DoGet("wizard/TestWizardWithArea/Page1.rails");
161 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstepindex", 0);
162 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstep", "Page1");
164 DoGet("wizard/TestWizardWithArea/Page1.rails");
165 AssertFlashDoesNotContain("InnerActionInvoked");
168 DoGet("wizard/TestWizardWithArea/Page1-InnerAction.rails");
170 AssertFlashContains("InnerActionInvoked");
172 DoGet("wizard/testwizardwitharea/Page4-InnerAction.rails", "navigate.to=uri:/wizard/TestWizardWithArea/Page3.rails" );
173 AssertRedirectedTo("/wizard/TestWizardWithArea/Page3.rails");
174 AssertFlashContains("InnerActionInvoked");
176 DoGet("wizard/TestWizardWithArea/Page4-InnerAction.rails", "navigate.to=uri:/wizard/TestWizardWithArea/Page3.rails" );
177 AssertRedirectedTo("/wizard/TestWizardWithArea/Page3.rails");
178 AssertFlashContains("InnerActionInvoked");
180 DoGet("wizard/TestWizardWithArea/Page4-InnerAction.rails", "navigate.to=uri:http://google/" );
181 AssertRedirectedTo("http://google/");
182 AssertFlashContains("InnerActionInvoked");