Minor changes to improve testability of helpers
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / Helpers / DictHelperTestCase.cs
blob4782e1e647b3f2a5d4930e2235ef1450410c163b
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;
18 using System.Collections;
20 using Castle.MonoRail.Framework.Helpers;
22 using NUnit.Framework;
25 [TestFixture]
26 public class DictHelperTestCase
28 private DictHelper helper;
30 [SetUp]
31 public void Init()
33 helper = new DictHelper();
36 [Test]
37 public void EmptyDict()
39 IDictionary dict = helper.CreateDict();
41 Assert.IsNotNull(dict);
42 Assert.AreEqual(0, dict.Count);
45 [Test]
46 public void SimpleDict()
48 IDictionary dict = helper.CreateDict("name=value", "other=somethingelse");
50 Assert.IsNotNull(dict);
51 Assert.AreEqual(2, dict.Count);
53 foreach(String key in dict.Keys)
55 if (key.Equals("name"))
57 Assert.AreEqual( "value", dict["name"] );
59 else if (key.Equals("other"))
61 Assert.AreEqual( "somethingelse", dict["other"] );
63 else
65 Assert.Fail("unexpected key? " + key);
70 [Test]
71 public void PushingParser()
73 IDictionary dict = helper.CreateDict("name=value=aa");
75 Assert.IsNotNull(dict);
76 Assert.AreEqual(1, dict.Count);
78 foreach(String key in dict.Keys)
80 if (key.Equals("name"))
82 Assert.AreEqual( "value=aa", dict["name"] );
84 else
86 Assert.Fail("unexpected key? " + key);