Minor changes to improve testability of helpers
[castle.git] / MonoRail / Castle.MonoRail.Framework.Tests / FlashTestCase.cs
blob67b30e8c77af88426f4655fa7f3afd02d2621f18
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
17 using NUnit.Framework;
19 using Castle.MonoRail.Framework;
21 [TestFixture]
22 public class FlashTestCase
24 [Test]
25 public void SimpleTest()
27 Flash flash = new Flash();
29 flash["test"] = "hello";
31 flash.Sweep();
33 Assert.IsTrue( flash.ContainsKey("test") );
35 flash = new Flash(flash);
37 Assert.IsTrue( flash.ContainsKey("test") );
40 [Test]
41 public void FlashNow()
43 Flash flash = new Flash();
45 flash.Now("test","hello");
47 Assert.IsTrue( flash.ContainsKey("test") );
49 flash.Sweep();
51 Assert.IsFalse( flash.ContainsKey("test") );
54 [Test]
55 public void FlashKeep()
57 Flash flash = new Flash();
59 flash.Now("test1","hello");
60 flash.Now("test2","hello");
62 flash.Keep("test1");
64 flash.Sweep();
66 Assert.IsTrue( flash.ContainsKey("test1") );
67 Assert.IsFalse( flash.ContainsKey("test2") );
69 flash = new Flash(flash);
70 flash.Sweep();
72 Assert.IsTrue( flash.Count == 0 );
74 flash.Now("test1","hello");
75 flash.Now("test2","hello");
77 flash.Keep();
79 flash.Sweep();
81 Assert.IsTrue( flash.ContainsKey("test1") );
82 Assert.IsTrue( flash.ContainsKey("test2") );
85 [Test]
86 public void FlashDiscard()
88 Flash flash = new Flash();
90 flash.Add("test1","hello");
91 flash.Add("test2","hello");
93 flash.Discard("test2");
95 flash.Sweep();
97 Assert.IsTrue( flash.ContainsKey("test1") );
98 Assert.IsFalse( flash.ContainsKey("test2") );
100 flash = new Flash(flash);
101 flash.Sweep();
103 Assert.IsTrue( flash.Count == 0 );
105 flash.Add("test1","hello");
106 flash.Add("test2","hello");
108 flash.Discard();
110 flash = new Flash(flash);
111 flash.Sweep();
113 Assert.IsFalse( flash.ContainsKey("test1") );
114 Assert.IsFalse( flash.ContainsKey("test2") );