Applying patch from Jonathon Rossi
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / ComponentsTestCase.cs
blobc2cea58084bbfea4510c76e5289adbd5d23a4cc7
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 SimpleInlineViewComponent()
26 string expected = "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2";
27 DoGet("usingcomponents/index1.rails");
28 AssertReplyEqualTo(expected);
31 [Test]
32 public void InlineComponentUsingRender()
34 string expected = "static 1\r\nThis is a view used by a component static 2";
35 DoGet("usingcomponents/index2.rails");
36 AssertReplyEqualTo(expected);
39 [Test]
40 public void InlineComponentNotOverridingRender()
42 string expected = "static 1\r\ndefault component view picked up automatically static 2";
43 DoGet("usingcomponents/index3.rails");
44 AssertReplyEqualTo(expected);
47 [Test]
48 public void InlineComponentWithParam1()
50 DoGet("usingcomponents/index4.rails");
51 AssertReplyEqualTo("Done");
54 [Test]
55 public void CanGetParamsFromTheComponentInTheView()
57 DoGet("usingcomponents/template.rails");
58 AssertReplyEqualTo("123");
61 [Test]
62 public void BlockComp1()
64 DoGet("usingcomponents/index8.rails");
65 AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n");
68 [Test]
69 public void SeveralComponentsInvocation()
71 for(int i = 0; i < 10; i++)
73 string expected =
74 "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";
75 DoGet("usingcomponents/index9.rails");
76 AssertReplyEqualTo(expected);
80 [Test]
81 public void UsingCaptureFor()
83 DoGet("usingcomponents/captureFor.rails");
84 AssertReplyEqualTo("\r\n1234 Foo, Bar");
87 [Test]
88 public void UsingCaptureForWithLayout()
90 DoGet("usingcomponents/captureForWithLayout.rails");
91 AssertReplyEqualTo("Numbers: 1234\r\n");
94 [Test]
95 public void CanPassParametersFromComponentToView()
97 DoGet("usingcomponents/withParams.rails");
98 AssertReplyEqualTo("brail");
101 [Test]
102 public void ComponentWithInvalidSection()
104 DoGet("usingcomponent2/ComponentWithInvalidSections.rails");
106 AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'");
109 [Test]
110 public void GridComponent1()
112 DoGet("usingcomponent2/GridComponent1.rails");
114 AssertReplyEqualTo(@"<table>
115 <th>EMail</th>
116 <th>Phone</th>
117 <tr>
118 <td>hammett</td>
119 <td>111</td>
120 </tr><tr>
121 <td>Peter Griffin</td>
122 <td>222</td>
123 </tr></table>");
126 [Test]
127 public void GridComponent2()
129 DoGet("usingcomponent2/GridComponent2.rails");
130 AssertReplyEqualTo(@"<table>
131 <th>EMail</th>
132 <th>Phone</th>
133 <tr>
134 <td colspan=2>Nothing here</td>
135 </tr></table>");