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
.Framework
.Tests
.Helpers
19 using NUnit
.Framework
;
21 using Castle
.MonoRail
.Framework
.Helpers
;
24 public class ValidationHelperTestCase
26 private ValidationHelper _helper
;
28 public ValidationHelperTestCase()
35 _helper
= new ValidationHelper();
38 [Test
, Ignore("We need to mock the controller and the request/context to be able to run this one")]
39 public void AutoScriptInstaller()
41 Assert
.AreEqual("<script type=\"text/javascript\" src=\"vdir/MonoRail/Files/ValidateConfig.rails\"></script>\r\n" +
42 "<script type=\"text/javascript\" src=\"vdir/MonoRail/Files/ValidateCore.rails\"></script>\r\n" +
43 "<script type=\"text/javascript\" src=\"vdir/MonoRail/Files/ValidateValidators.rails\"></script>\r\n"+
44 "<script type=\"text/javascript\" src=\"vdir/MonoRail/Files/ValidateLang.rails\"></script>\r\n",
45 _helper
.InstallScripts());
49 public void DefaultValidationTriggerFunction()
51 Assert
.AreEqual("return validateForm( this, false, false, false, false, 0 );",
52 _helper
.GetValidationTriggerFunction());
56 public void CustomValidationTriggerFunction()
58 Assert
.AreEqual("return validateForm( document.forms[0], false, false, false, false, 0 );",
59 _helper
.GetValidationTriggerFunction("document.forms[0]"));
63 public void OverrideDefaults()
65 _helper
.SetSubmitOptions(true, true, true, 1);
67 Assert
.AreEqual("return validateForm( this, true, true, true, true, 1 );",
68 _helper
.GetValidationTriggerFunction());