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
.Views
.Brail
.Tests
17 using Castle
.MonoRail
.Framework
.Tests
;
18 using NUnit
.Framework
;
21 public class ComponentsTestCase
: AbstractTestCase
24 public void BlockComp1()
26 DoGet("usingcomponents/index8.rails");
27 AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n");
31 public void CanGetParamsFromTheComponentInTheView()
33 DoGet("usingcomponents/template.rails");
34 AssertReplyEqualTo("123");
38 public void CanPassParametersFromComponentToView()
40 DoGet("usingcomponents/withParams.rails");
41 AssertReplyEqualTo("brail");
45 public void ComponentWithInvalidSection()
47 DoGet("usingcomponent2/ComponentWithInvalidSections.rails");
49 AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'");
53 public void GridComponent1()
55 DoGet("usingcomponent2/GridComponent1.rails");
65 <td>Peter Griffin</td>
71 public void GridComponent2()
73 DoGet("usingcomponent2/GridComponent2.rails");
79 <td colspan=2>Nothing here</td>
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
);
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
);
100 public void InlineComponentWithParam1()
102 DoGet("usingcomponents/index4.rails");
103 AssertReplyEqualTo("Done");
107 public void SeveralComponentsInvocation()
109 for (int i
= 0; i
< 10; i
++)
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
);
119 public void SimpleInlineViewComponent()
121 string expected
= "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2";
122 DoGet("usingcomponents/index1.rails");
123 AssertReplyEqualTo(expected
);
127 public void UsingCaptureFor()
129 DoGet("usingcomponents/captureFor.rails");
130 AssertReplyEqualTo("\r\n1234 Foo, Bar");
134 public void UsingCaptureForWithLayout()
136 DoGet("usingcomponents/captureForWithLayout.rails");
137 AssertReplyEqualTo("Numbers: 1234\r\n");