Fixing a bug with the new FixTryGetParameterConditionalChecks - which would always...
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / ComponentsTestCase.cs
blob571800fcabd6e7283d5d3c103410f6712410ac1e
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.Views.Brail.Tests
17 using Castle.MonoRail.Framework.Tests;
18 using NUnit.Framework;
20 [TestFixture]
21 public class ComponentsTestCase : AbstractTestCase
23 [Test]
24 public void BlockComp1()
26 DoGet("usingcomponents/index8.rails");
27 AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n");
30 [Test]
31 public void CanGetParamsFromTheComponentInTheView()
33 DoGet("usingcomponents/template.rails");
34 AssertReplyEqualTo("123");
37 [Test]
38 public void CanPassParametersFromComponentToView()
40 DoGet("usingcomponents/withParams.rails");
41 AssertReplyEqualTo("brail");
44 [Test]
45 public void ComponentWithInvalidSection()
47 DoGet("usingcomponent2/ComponentWithInvalidSections.rails");
49 AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'");
52 [Test]
53 public void GridComponent1()
55 DoGet("usingcomponent2/GridComponent1.rails");
57 AssertReplyEqualTo(
58 @"<table>
59 <th>EMail</th>
60 <th>Phone</th>
61 <tr>
62 <td>hammett</td>
63 <td>111</td>
64 </tr><tr>
65 <td>Peter Griffin</td>
66 <td>222</td>
67 </tr></table>");
70 [Test]
71 public void GridComponent2()
73 DoGet("usingcomponent2/GridComponent2.rails");
74 AssertReplyEqualTo(
75 @"<table>
76 <th>EMail</th>
77 <th>Phone</th>
78 <tr>
79 <td colspan=2>Nothing here</td>
80 </tr></table>");
83 [Test]
84 public void InlineComponentNotOverridingRender()
86 string expected = "static 1\r\ndefault component view picked up automatically static 2";
87 DoGet("usingcomponents/index3.rails");
88 AssertReplyEqualTo(expected);
91 [Test]
92 public void InlineComponentUsingRender()
94 string expected = "static 1\r\nThis is a view used by a component static 2";
95 DoGet("usingcomponents/index2.rails");
96 AssertReplyEqualTo(expected);
99 [Test]
100 public void InlineComponentWithParam1()
102 DoGet("usingcomponents/index4.rails");
103 AssertReplyEqualTo("Done");
106 [Test]
107 public void SeveralComponentsInvocation()
109 for (int i = 0; i < 10; i++)
111 string expected =
112 "static 1\r\nContent 1\r\nstatic 2\r\nContent 2\r\nstatic 3\r\nContent 3\r\nstatic 4\r\nContent 4\r\nstatic 5\r\nContent 5\r\n";
113 DoGet("usingcomponents/index9.rails");
114 AssertReplyEqualTo(expected);
118 [Test]
119 public void SimpleInlineViewComponent()
121 string expected = "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2";
122 DoGet("usingcomponents/index1.rails");
123 AssertReplyEqualTo(expected);
126 [Test]
127 public void UsingCaptureFor()
129 DoGet("usingcomponents/captureFor.rails");
130 AssertReplyEqualTo("\r\n1234 Foo, Bar");
133 [Test]
134 public void UsingCaptureForWithLayout()
136 DoGet("usingcomponents/captureForWithLayout.rails");
137 AssertReplyEqualTo("Numbers: 1234\r\n");