Simple impl to MockRailsEngineContext.Url
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / MockCacheProvider.cs
blob40c90843e8bca011963a3e47c3bbb11b136a8ff1
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.Test
17 using System;
18 using System.Collections;
19 using System.Collections.Specialized;
21 /// <summary>
22 /// Represents a mock implementation of <see cref="ICacheProvider"/> for unit test purposes.
23 /// </summary>
24 public class MockCacheProvider : ICacheProvider
26 private IDictionary dictionary = new HybridDictionary(true);
28 /// <summary>
29 /// Services the specified provider.
30 /// </summary>
31 /// <param name="provider">The provider.</param>
32 public void Service(IServiceProvider provider)
36 /// <summary>
37 /// Determines whether the specified key is on the cache.
38 /// </summary>
39 /// <param name="key">The key.</param>
40 /// <returns>
41 /// <c>true</c> if the cache has the key; otherwise, <c>false</c>.
42 /// </returns>
43 public bool HasKey(string key)
45 return dictionary.Contains(key);
48 /// <summary>
49 /// Gets the cache item by the specified key.
50 /// </summary>
51 /// <param name="key">The key.</param>
52 /// <returns></returns>
53 public object Get(string key)
55 return dictionary[key];
58 /// <summary>
59 /// Stores the cache item by the specified key.
60 /// </summary>
61 /// <param name="key">The key.</param>
62 /// <param name="data">The data.</param>
63 public void Store(string key, object data)
65 dictionary[key] = data;
68 /// <summary>
69 /// Deletes the cache item by the specified key.
70 /// </summary>
71 /// <param name="key">The key.</param>
72 public void Delete(string key)
74 dictionary.Remove(key);