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 SimpleInlineViewComponent()
26 string expected
= "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2";
27 DoGet("usingcomponents/index1.rails");
28 AssertReplyEqualTo(expected
);
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
);
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
);
48 public void InlineComponentWithParam1()
50 DoGet("usingcomponents/index4.rails");
51 AssertReplyEqualTo("Done");
55 public void CanGetParamsFromTheComponentInTheView()
57 DoGet("usingcomponents/template.rails");
58 AssertReplyEqualTo("123");
62 public void BlockComp1()
64 DoGet("usingcomponents/index8.rails");
65 AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n");
69 public void SeveralComponentsInvocation()
71 for(int i
= 0; i
< 10; i
++)
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
);
81 public void UsingCaptureFor()
83 DoGet("usingcomponents/captureFor.rails");
84 AssertReplyEqualTo("\r\n1234 Foo, Bar");
88 public void UsingCaptureForWithLayout()
90 DoGet("usingcomponents/captureForWithLayout.rails");
91 AssertReplyEqualTo("Numbers: 1234\r\n");
95 public void CanPassParametersFromComponentToView()
97 DoGet("usingcomponents/withParams.rails");
98 AssertReplyEqualTo("brail");
102 public void ComponentWithInvalidSection()
104 DoGet("usingcomponent2/ComponentWithInvalidSections.rails");
106 AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'");
110 public void GridComponent1()
112 DoGet("usingcomponent2/GridComponent1.rails");
114 AssertReplyEqualTo(@"<table>
121 <td>Peter Griffin</td>
127 public void GridComponent2()
129 DoGet("usingcomponent2/GridComponent2.rails");
130 AssertReplyEqualTo(@"<table>
134 <td colspan=2>Nothing here</td>