Support multiple service models for a component. WindsorServiceHostFactory will...
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail.Tests / JSGenerationTestCase.cs
blob4385d41a64f4da2530a75e5c6dac0c3ad317e64c
1 // Copyright 2004-2008 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
18 using NUnit.Framework;
20 [TestFixture]
21 public class JSGenerationTestCase : BaseViewOnlyTestFixture
23 [Test]
24 public void AccessingElementAttribute()
26 ProcessViewJS("jsgeneration/elementattribute");
27 AssertReplyContains("$('aa').className = \"newclass\";");
30 [Test]
31 public void AccessingElementAttributeDepth()
33 ProcessViewJS("jsgeneration/elementattributedepth");
34 AssertReplyContains("$('aa').style.display = \"none\";");
37 [Test]
38 public void AccessingElementMethod()
40 ProcessViewJS("jsgeneration/elementmethod");
41 AssertReplyContains("$('aa').hide();");
44 [Test]
45 public void AccessingElementMethodDepth()
47 ProcessViewJS("jsgeneration/elementmethoddepth");
48 AssertReplyContains("$('aa').read().test();");
51 [Test]
52 public void AccessingElementStockOperationReplace()
54 ProcessViewJS("jsgeneration/elementreplace");
55 AssertReplyContains("$('aa').replace(\"new content\")");
58 [Test]
59 public void AccessingElementStockOperationReplaceHtml()
61 ProcessViewJS("jsgeneration/elementreplacehtml");
62 AssertReplyContains("$('aa').replacehtml(\"new content\")");
65 [Test]
66 public void CollectionFirstLast()
68 ProcessViewJS("jsgeneration/collectionfirstlast");
69 AssertReplyContains("$('p.welcome b').first().hide();");
70 AssertReplyContains("$('p.welcome b').last().show();");
73 [Test]
74 public void InsertHtml()
76 ProcessViewJS("jsgeneration/InsertHtml");
77 AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");");
78 AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");");
79 AssertReplyContains("new Insertion.After(\"aa\",\"new content\");");
80 AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");");
83 [Test]
84 public void MR_264()
86 ProcessViewJS("jsgeneration/mr264");
87 AssertReplyContains(
88 "Element.update(\"holder\",\"test\");\r\n" +
89 "new Effect.Highlight('holder', {});");
92 [Test]
93 public void Replace()
95 ProcessViewJS("jsgeneration/replace");
96 AssertReplyContains("Element.replace(\"aa\",\"new content\")");
99 [Test]
100 public void ReplaceHtml()
102 ProcessViewJS("jsgeneration/replacehtml");
103 AssertReplyContains("Element.update(\"aa\",\"new content\");");
106 [Test]
107 public void ReplaceHtmlUsingPartial()
109 PropertyBag["Name"] = "hammett";
110 PropertyBag["list"] = new string[] {"a", "b"};
112 ProcessViewJS("jsgeneration/replacehtmlwithpartial");
113 AssertReplyContains("Element.update(\"aa\",\"You\'re hammett <br> [ a ][ b ]\")");
116 [Test]
117 public void ShowHideToggleRemove()
119 ProcessViewJS("jsgeneration/multipleactions");
120 AssertReplyContains("Element.show(\"a\");");
121 AssertReplyContains("Element.show(\"a\",\"b\",\"c\");");
122 AssertReplyContains("Element.hide(\"a\");");
123 AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");");
124 AssertReplyContains("Element.toggle(\"a\");");
125 AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");");
126 AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);");
129 [Test]
130 public void SimpleElementAccess()
132 ProcessViewJS("jsgeneration/elementaccess");
133 AssertReplyContains("$('aa');");
136 [Test]
137 public void VisualEffect()
139 ProcessViewJS("jsgeneration/visualeffect");
140 AssertReplyContains("Effect.Highlight('element1', {});");
141 AssertReplyContains("Effect.Highlight('element1', {duration:4});");