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
18 using System
.Threading
;
19 using Castle
.MonoRail
.Framework
.Tests
;
20 using NUnit
.Framework
;
23 public class BrailBasicFunctionality
: AbstractTestCase
28 DoGet("apppath/index.rails");
29 AssertReplyEqualTo("Current apppath is ");
32 [Test
, Ignore("Sometimes fail, but the functionality is working.")]
33 public void AppPathChangeOnTheFly()
35 string script
= Path
.Combine(GetPhysicalDir(), @"Views\AppPath\Index.boo");
36 string newContent
= "new content";
38 using(TextReader read
= File
.OpenText(script
))
40 old
= read
.ReadToEnd();
42 using(TextWriter write
= File
.CreateText(script
))
44 write
.Write(newContent
);
46 // Wait half a sec so Brail could pick up that a change in the file occured.
50 DoGet("apppath/index.rails");
51 AssertReplyEqualTo(newContent
);
55 using(TextWriter write
= File
.CreateText(script
))
63 public void CommonScripts()
65 DoGet("home/nullables.rails");
66 string expected
= "\r\nfoo";
67 AssertReplyEqualTo(expected
);
73 DoGet("home/Empty.rails");
75 AssertReplyEqualTo(expected
);
78 [Test
, Ignore("Sometimes fail, but the functionality is working.")]
79 public void CommonScriptsChangeOnTheFly()
81 string common
= Path
.Combine(GetPhysicalDir(), @"Views\CommonScripts\Hello.boo");
83 using(TextReader read
= File
.OpenText(common
))
85 old
= read
.ReadToEnd();
88 def SayHello(name as string):
89 return 'Hello, \${name}! Modified!'
91 using(TextWriter write
= File
.CreateText(common
))
95 string expected
= "Hello, Ayende! Modified!";
96 // Have to wait for the common scripts recompilation otherwise you get random test failure since the request
97 // sometimes gets there faster you can recompile and it gets the old version.
101 DoGet("home/hellofromcommon.rails");
102 AssertReplyEqualTo(expected
);
106 using(TextWriter write
= File
.CreateText(common
))
111 // Have to wait again to make sure that the second recompilation happened, since otherwise a second test
112 // might get the modified version.
117 public void PreProcessor()
119 DoGet("home/preprocessor.rails");
124 <title>AYENDE</title>
127 <li>0</li><li>1</li><li>2</li>
132 AssertReplyEqualTo(expected
);