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 System
.Collections
;
18 using System
.Collections
.Generic
;
19 using NUnit
.Framework
;
22 public class BrailRegressionTestFixture
: BaseViewOnlyTestFixture
24 public BrailRegressionTestFixture()
25 : base("../../../Castle.MonoRail.Views.Brail.Tests")
31 public void CanCompareToNullableParameter()
33 PropertyBag
["myVariable"] = "Hello";
34 ProcessView("regressions/CanCompareToNullableParameter");
35 AssertReplyEqualTo("Eq");
39 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter()
41 ProcessView("regressions/questionMarkOp_if");
42 AssertReplyEqualTo("");
46 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenPassed()
48 PropertyBag
["errorMsg"] = "Hello";
49 ProcessView("regressions/questionMarkOp_if_whenPassed");
50 AssertReplyEqualTo("Hello");
54 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenExists()
56 PropertyBag
["Errors"] = new string[] {"Hello",}
;
57 ProcessView("regressions/questionMarkOp_if_when_exists");
58 AssertReplyEqualTo("Hello<br />\r\n");
63 public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenMissing()
65 ProcessView("regressions/questionMarkOp_if_when_missing");
66 AssertReplyEqualTo("");
70 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter()
72 string view
= ProcessView("regressions/questionMarkOp_unless");
73 Assert
.AreEqual("\r\nError does not exist\r\n", view
);
77 public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter_whenPassed()
80 PropertyBag
["errorMsg"] = "Hello";
81 string view
= ProcessView("regressions/questionMarkOp_unless_whenPassed");
82 Assert
.AreEqual("", view
);
87 public void HtmlEncodingStringInterpolation()
89 PropertyBag
["htmlCode"] = "<script>alert('a');</script>";
90 string view
= ProcessView("regressions/HtmlEncodingStringInterpolation");
91 Assert
.AreEqual("<script>alert('a');</script>", view
);
95 public void StringInterpolationInCodeBlockWillNotBeEscaped()
97 PropertyBag
["htmlCode"] = "<script>alert('a');</script>";
98 string view
= ProcessView("regressions/StringInterpolationInCodeBlockWillNotBeEscaped");
99 Assert
.AreEqual("<script>alert('a');</script>", view
);
103 public void CanUseViewFromResource()
105 string view
= ProcessView("login/welcome");
106 Assert
.AreEqual("Hi there, anonymous user!", view
);