Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Framework.Views.NVelocity.Tests / WizardSupportTestCase.cs
blobe832bca0eaea9993cfb27bbbcb8ee9f3097ac78a
1 // Copyright 2004-2007 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.Views.NVelocity.Tests
17 using Castle.MonoRail.Framework.Tests;
18 using NUnit.Framework;
20 [TestFixture]
21 public class WizardSupportTestCase : AbstractTestCase
23 [Test]
24 public void StartRedirectsToFirstPage()
26 DoGet("testwizard/start.rails");
27 AssertRedirectedTo("/testwizard/Page1.rails");
30 [Test]
31 public void UnrelatedWizardActionInvocation()
33 DoGet("testwizard/index.rails");
34 AssertReplyEqualTo("Hello!");
37 [Test]
38 public void Page1HasCorrectIndex()
40 DoGet("testwizard/Page1.rails");
41 AssertSuccess();
42 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 0);
43 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page1");
45 // Yes, we invoke it twice
47 DoGet("testwizard/Page1.rails");
48 AssertSuccess();
49 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 0);
50 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page1");
52 DoGet("testwizard/Page2.rails");
53 AssertSuccess();
54 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstepindex", 1);
55 AssertSessionEntryEqualsTo("wizard.testwizardcurrentstep", "Page2");
58 [Test]
59 public void InnerActionsWithNoView()
61 DoGet("testwizard/Page1.rails");
62 AssertFlashDoesNotContain("InnerActionInvoked");
63 AssertSuccess();
65 // Yes, we invoke it twice
67 DoGet("testwizard/Page1.rails");
68 AssertSuccess();
69 AssertFlashDoesNotContain("InnerActionInvoked");
71 DoGet("testwizard/Page1-InnerAction.rails");
72 AssertSuccess();
73 AssertFlashContains("InnerActionInvoked");
76 [Test]
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");
92 [Test]
93 public void InnerActionsWithView()
95 DoGet("testwizard/Page1-InnerAction2.rails");
96 AssertSuccess();
97 AssertReplyEqualTo("View for Inner action 2");
100 [Test]
101 public void WizardPageWithView()
103 DoGet("testwizard/Page3.rails");
104 AssertSuccess();
105 AssertReplyEqualTo("Wizard page 3");
108 [Test]
109 public void WizardHelper_HasNextAndPreviousSteps()
111 DoGet("testwizard/Page4.rails");
112 AssertSuccess();
113 AssertReplyEqualTo("hasprevious True\r\nhasnext False");
116 [Test]
117 public void ConditionalWizardSteps()
119 DoGet("testwizardconditions/index.rails");
120 AssertSuccess();
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");
133 AssertSuccess();
134 AssertReplyEqualTo("Wizard page 1");
136 DoGet("testwizardconditions/page1-InnerAction.rails", "id=1");
137 AssertSuccess();
138 AssertReplyEqualTo("InnerAction contents");
140 DoGet("testwizardconditions/page1-InnerAction2.rails", "id=1");
141 AssertSuccess();
142 AssertReplyEqualTo("View for Inner action 2");
145 [Test]
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");
155 AssertSuccess();
156 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstepindex", 0);
157 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstep", "Page1");
159 DoGet("wizard/TestWizardWithArea/Page1.rails");
160 AssertSuccess();
161 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstepindex", 0);
162 AssertSessionEntryEqualsTo("wizard.testwizardwithareacurrentstep", "Page1");
164 DoGet("wizard/TestWizardWithArea/Page1.rails");
165 AssertFlashDoesNotContain("InnerActionInvoked");
166 AssertSuccess();
168 DoGet("wizard/TestWizardWithArea/Page1-InnerAction.rails");
169 AssertSuccess();
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");