1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
20 using Castle
.MonoRail
.Framework
.Helpers
;
22 using NUnit
.Framework
;
26 public class DictHelperTestCase
28 private DictHelper helper
;
33 helper
= new DictHelper();
37 public void EmptyDict()
39 IDictionary dict
= helper
.CreateDict();
41 Assert
.IsNotNull(dict
);
42 Assert
.AreEqual(0, dict
.Count
);
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"] );
65 Assert
.Fail("unexpected key? " + key
);
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"] );
86 Assert
.Fail("unexpected key? " + key
);