Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / MonoRail / Castle.MonoRail.Framework.Views.NVelocity.Tests / JSGenerationTestCase.cs
blob2055a3466478f4d175e0793cfee5d92b41305733
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.Framework.Views.NVelocity.Tests
17 using Castle.MonoRail.Framework.Tests;
18 using NUnit.Framework;
20 [TestFixture]
21 public class JSGenerationTestCase : AbstractTestCase
23 #region Stock operations
25 [Test]
26 public void ReplaceHtml()
28 DoGet("jsgeneration/replacehtml.rails");
29 AssertSuccess();
30 AssertReplyContains("Element.update(\"aa\",\"new content\");");
33 [Test]
34 public void ReplaceHtmlUsingPartial()
36 DoGet("jsgeneration/replacehtmlwithpartial.rails");
37 AssertSuccess();
38 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
41 [Test]
42 public void Replace()
44 DoGet("jsgeneration/replace.rails");
45 AssertSuccess();
46 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
49 [Test]
50 public void InsertHtml()
52 DoGet("jsgeneration/InsertHtml.rails");
53 AssertSuccess();
54 AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");");
55 AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");");
56 AssertReplyContains("new Insertion.After(\"aa\",\"new content\");");
57 AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");");
60 [Test]
61 public void VisualEffect()
63 DoGet("jsgeneration/visualeffect.rails");
64 AssertSuccess();
65 AssertReplyContains("Effect.Highlight('element1', {});");
66 AssertReplyContains("Effect.Highlight('element1', {duration:4});");
69 [Test]
70 public void ShowHideToggleRemove()
72 DoGet("jsgeneration/multipleactions.rails");
73 AssertSuccess();
74 AssertReplyContains("Element.show(\"a\");");
75 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
76 AssertReplyContains("Element.hide(\"a\");");
77 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
78 AssertReplyContains("Element.toggle(\"a\");");
79 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
80 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
83 #endregion
85 #region Element related
87 [Test]
88 public void SimpleElementAccess()
90 DoGet("jsgeneration/elementaccess.rails");
91 AssertSuccess();
92 AssertReplyContains("$('aa');");
95 [Test]
96 public void AccessingElementAttribute()
98 DoGet("jsgeneration/elementattribute.rails");
99 AssertSuccess();
100 AssertReplyContains("$('aa').className = \"newclass\";");
103 [Test]
104 public void AccessingElementAttributeDepth()
106 DoGet("jsgeneration/elementattributedepth.rails");
107 AssertSuccess();
108 AssertReplyContains("$('aa').style.display = \"none\";");
111 [Test]
112 public void AccessingElementMethod()
114 DoGet("jsgeneration/elementmethod.rails");
115 AssertSuccess();
116 AssertReplyContains("$('aa').hide();");
119 [Test]
120 public void AccessingElementMethodDepth()
122 DoGet("jsgeneration/elementmethoddepth.rails");
123 AssertSuccess();
124 AssertReplyContains("$('aa').read().test();");
127 [Test]
128 public void AccessingElementStockOperationReplaceHtml()
130 DoGet("jsgeneration/elementreplacehtml.rails");
131 AssertSuccess();
132 AssertReplyContains("$('aa').update(\"new content\")");
135 [Test]
136 public void AccessingElementStockOperationReplace()
138 DoGet("jsgeneration/elementreplace.rails");
139 AssertSuccess();
140 AssertReplyContains("$('aa').replace(\"new content\")");
143 #endregion
145 #region Select related
147 [Test]
148 public void SimpleCollectionAccess()
150 DoGet("jsgeneration/collectionaccess.rails");
151 AssertSuccess();
152 AssertReplyContains("$$('aa');");
155 [Test]
156 public void CollectionFirstLast()
158 DoGet("jsgeneration/collectionfirstlast.rails");
159 AssertSuccess();
160 AssertReplyContains("$$('p.welcome b').first().hide();");
161 AssertReplyContains("$$('p.welcome b').last().show();");
164 #endregion