1 // Copyright 2004-2008 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 NUnit
.Framework
;
20 public class BrailRegressionTestFixture
: BaseViewOnlyTestFixture
22 public BrailRegressionTestFixture()
23 : base(ViewLocations
.BrailTestsView
)
29 public void CanCompareToNullableParameter()
31 PropertyBag
["myVariable"] = "Hello";
32 ProcessView("regressions/CanCompareToNullableParameter");
33 AssertReplyEqualTo("Eq");
37 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter()
39 ProcessView("regressions/questionMarkOp_if");
40 AssertReplyEqualTo("");
44 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenPassed()
46 PropertyBag
["errorMsg"] = "Hello";
47 ProcessView("regressions/questionMarkOp_if_whenPassed");
48 AssertReplyEqualTo("Hello");
52 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenExists()
54 PropertyBag
["Errors"] = new string[] {"Hello",}
;
55 ProcessView("regressions/questionMarkOp_if_when_exists");
56 AssertReplyEqualTo("Hello<br />\r\n");
61 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenMissing()
63 ProcessView("regressions/questionMarkOp_if_when_missing");
64 AssertReplyEqualTo("");
68 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter()
70 string view
= ProcessView("regressions/questionMarkOp_unless");
71 Assert
.AreEqual("\r\nError does not exist\r\n", view
);
75 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter_whenPassed()
78 PropertyBag
["errorMsg"] = "Hello";
79 string view
= ProcessView("regressions/questionMarkOp_unless_whenPassed");
80 Assert
.AreEqual("", view
);
85 public void HtmlEncodingStringInterpolation()
87 PropertyBag
["htmlCode"] = "<script>alert('a');</script>";
88 string view
= ProcessView("regressions/HtmlEncodingStringInterpolation");
89 Assert
.AreEqual("<script>alert('a');</script>", view
);
93 public void StringInterpolationInCodeBlockWillNotBeEscaped()
95 PropertyBag
["htmlCode"] = "<script>alert('a');</script>";
96 string view
= ProcessView("regressions/StringInterpolationInCodeBlockWillNotBeEscaped");
97 Assert
.AreEqual("<script>alert('a');</script>", view
);
101 public void CanUseViewFromResource()
103 string view
= ProcessView("login/welcome");
104 Assert
.AreEqual("Hi there, anonymous user!", view
);