Minor changes to improve testability of helpers
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Helpers / AbstractHelperTestCase.cs
blob1340856e227a97f4f5ba597ae224b4bbbc2626f1
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.Tests.Helpers
17 using System.Collections;
18 using System.Collections.Specialized;
19 using Castle.MonoRail.Framework.Helpers;
20 using Castle.MonoRail.Framework.Test;
21 using NUnit.Framework;
23 [TestFixture]
24 public class AbstractHelperTestCase
26 private DummyHelper helper;
28 [SetUp]
29 public void Init()
31 helper = new DummyHelper();
32 helper.ServerUtility = new MockServerUtility();
35 [Test]
36 public void BuildQueryString()
38 IDictionary parameters = new ListDictionary();
39 parameters.Add("single", 1);
40 parameters.Add("multiple", new int[] {2, 4, 99});
41 parameters.Add("string", "test");
43 string queryString = helper.BuildQueryString(parameters);
45 Assert.AreEqual("single=1&multiple=2&multiple=4&multiple=99&string=test", queryString);
48 [Test]
49 public void BuildQueryStringUsingNameValueCollection()
51 NameValueCollection parameters = new NameValueCollection();
52 parameters.Add("single", "1");
53 parameters.Add("multiple", "2");
54 parameters.Add("multiple", "4");
55 parameters.Add("multiple", "99");
56 parameters.Add("string", "test");
58 string queryString = helper.BuildQueryString(parameters);
60 Assert.AreEqual("single=1&multiple=2&multiple=4&multiple=99&string=test", queryString);
63 internal class DummyHelper : AbstractHelper
65 public new string BuildQueryString(IDictionary parameters)
67 return base.BuildQueryString(parameters);
70 public new string BuildQueryString(NameValueCollection parameters)
72 return base.BuildQueryString(parameters);
75 public override string HtmlEncode(string content)
77 return content;
80 public override string UrlEncode(string content)
82 return content;