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 Castle
.MonoRail
.Framework
.Tests
;
18 using NUnit
.Framework
;
21 public class BrailAjaxTestCase
: AbstractTestCase
24 public void BuildFormRemoteTag()
26 DoGet("ajax/BuildFormRemoteTag.rails");
28 "<form onsubmit=\"new Ajax.Request('url', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\" enctype=\"multipart/form-data\" action=\"url\" method=\"post\" >";
30 AssertReplyEqualTo(expected
);
34 public void JsFunctions()
36 DoGet("ajax/JsFunctions.rails");
37 string expected
= "<script type=\"text/javascript\" src=\"/MonoRail/Files/AjaxScripts.rails?RC3_0006\"></script>";
39 AssertReplyEqualTo(expected
);
43 public void LinkToFunction()
45 DoGet("ajax/LinkToFunction.rails");
47 "<a href=\"javascript:void(0);\" onclick=\"alert('Ok'); return false;\" ><img src='myimg.gid'></a>";
49 AssertReplyEqualTo(expected
);
53 public void LinkToRemote()
55 DoGet("ajax/LinkToRemote.rails");
57 "<a href=\"javascript:void(0);\" onclick=\"new Ajax.Request('/controller/action.rails', {asynchronous:true, evalScripts:true}); return false;\" ><img src='myimg.gid'></a>";
59 AssertReplyEqualTo(expected
);
63 public void ObserveField()
65 DoGet("ajax/ObserveField.rails");
67 "<script type=\"text/javascript\">new Form.Element.Observer('myfieldid', 2, function(element, value) { new Ajax.Updater('elementToBeUpdated', '/url', {asynchronous:true, evalScripts:true, parameters:newcontent}) })</script>";
69 AssertReplyEqualTo(expected
);
73 public void ObserveForm()
75 DoGet("ajax/ObserveForm.rails");
77 "<script type=\"text/javascript\">new Form.Observer('myfieldid', 2, function(element, value) { new Ajax.Updater('elementToBeUpdated', '/url', {asynchronous:true, evalScripts:true, parameters:newcontent}) })</script>";
79 AssertReplyEqualTo(expected
);