Added DictionaryAdapter.build.
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / BrailAjaxTestCase.cs
blob1bcc086ce4a33e5154c64bc64fc76e8962290712
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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;
20 [TestFixture]
21 public class BrailAjaxTestCase : AbstractTestCase
23 [Test]
24 public void JsFunctions()
26 DoGet("ajax/JsFunctions.rails");
27 string expected = "<script type=\"text/javascript\" src=\"/MonoRail/Files/AjaxScripts.rails?RC3_0006\"></script>";
28 AssertSuccess();
29 AssertReplyEqualTo(expected);
32 [Test]
33 public void LinkToFunction()
35 DoGet("ajax/LinkToFunction.rails");
36 string expected =
37 "<a href=\"javascript:void(0);\" onclick=\"alert('Ok'); return false;\" ><img src='myimg.gid'></a>";
38 AssertSuccess();
39 AssertReplyEqualTo(expected);
42 [Test]
43 public void LinkToRemote()
45 DoGet("ajax/LinkToRemote.rails");
46 string expected =
47 "<a href=\"javascript:void(0);\" onclick=\"new Ajax.Request('/controller/action.rails', {asynchronous:true, evalScripts:true}); return false;\" ><img src='myimg.gid'></a>";
48 AssertSuccess();
49 AssertReplyEqualTo(expected);
52 [Test]
53 public void BuildFormRemoteTag()
55 DoGet("ajax/BuildFormRemoteTag.rails");
56 string expected =
57 "<form onsubmit=\"new Ajax.Request('url', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\" enctype=\"multipart/form-data\" action=\"url\" method=\"post\" >";
58 AssertSuccess();
59 AssertReplyEqualTo(expected);
62 [Test]
63 public void ObserveField()
65 DoGet("ajax/ObserveField.rails");
66 string expected =
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>";
68 AssertSuccess();
69 AssertReplyEqualTo(expected);
72 [Test]
73 public void ObserveForm()
75 DoGet("ajax/ObserveForm.rails");
76 string expected =
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>";
78 AssertSuccess();
79 AssertReplyEqualTo(expected);