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 System
.Collections
;
18 using NUnit
.Framework
;
21 public class BrailRegressionTestFixture
: BaseViewOnlyTestFixture
24 public void CanCompareToNullableParameter()
26 Hashtable args
= new Hashtable();
27 args
["myVariable"] = "Hello";
28 string view
= ProcessView(args
, "regressions/CanCompareToNullableParameter");
29 Assert
.AreEqual("Eq", view
);
33 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter()
35 string view
= ProcessView("regressions/questionMarkOp_if");
36 Assert
.AreEqual("", view
);
40 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenPassed()
42 Hashtable args
= new Hashtable();
43 args
["errorMsg"] = "Hello";
44 string view
= ProcessView(args
, "regressions/questionMarkOp_if_whenPassed");
45 Assert
.AreEqual("Hello", view
);
49 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenExists()
51 Hashtable args
= new Hashtable();
52 args
["Errors"] = new string[] {"Hello",}
;
53 string view
= ProcessView(args
, "regressions/questionMarkOp_if_when_exists");
54 Assert
.AreEqual("Hello<br />\r\n", view
);
59 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenMissing()
61 Hashtable args
= new Hashtable();
62 string view
= ProcessView(args
, "regressions/questionMarkOp_if_when_missing");
63 Assert
.AreEqual("", view
);
67 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter()
69 string view
= ProcessView("regressions/questionMarkOp_unless");
70 Assert
.AreEqual("\r\nError does not exist\r\n", view
);
74 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter_whenPassed()
76 Hashtable args
= new Hashtable();
77 args
["errorMsg"] = "Hello";
78 string view
= ProcessView(args
, "regressions/questionMarkOp_unless_whenPassed");
79 Assert
.AreEqual("", view
);
84 public void HtmlEncodingStringInterpolation()
86 Hashtable args
= new Hashtable();
87 args
["htmlCode"] = "<script>alert('a');</script>";
88 string view
= ProcessView(args
, "regressions/HtmlEncodingStringInterpolation");
89 Assert
.AreEqual("<script>alert('a');</script>", view
);
93 public void StringInterpolationInCodeBlockWillNotBeEscaped()
95 Hashtable args
= new Hashtable();
96 args
["htmlCode"] = "<script>alert('a');</script>";
97 string view
= ProcessView(args
, "regressions/StringInterpolationInCodeBlockWillNotBeEscaped");
98 Assert
.AreEqual("<script>alert('a');</script>", view
);
102 public void CanUseViewFromResource()
104 string view
= ProcessView("login/welcome");
105 Assert
.AreEqual("Hi there, anonymous user!", view
);