Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / MockCacheProvider.cs
blobb36815171ccd81eb4e1214c81c5f47da2544c1bc
1 // Copyright 2004-2008 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.Collections;
18 using System.Collections.Specialized;
20 /// <summary>
21 /// Represents a mock implementation of <see cref="ICacheProvider"/> for unit test purposes.
22 /// </summary>
23 public class MockCacheProvider : ICacheProvider
25 private IDictionary dictionary = new HybridDictionary(true);
27 /// <summary>
28 /// Services the specified provider.
29 /// </summary>
30 /// <param name="provider">The provider.</param>
31 public void Service(IMonoRailServices provider)
35 /// <summary>
36 /// Determines whether the specified key is on the cache.
37 /// </summary>
38 /// <param name="key">The key.</param>
39 /// <returns>
40 /// <c>true</c> if the cache has the key; otherwise, <c>false</c>.
41 /// </returns>
42 public bool HasKey(string key)
44 return dictionary.Contains(key);
47 /// <summary>
48 /// Gets the cache item by the specified key.
49 /// </summary>
50 /// <param name="key">The key.</param>
51 /// <returns></returns>
52 public object Get(string key)
54 return dictionary[key];
57 /// <summary>
58 /// Stores the cache item by the specified key.
59 /// </summary>
60 /// <param name="key">The key.</param>
61 /// <param name="data">The data.</param>
62 public void Store(string key, object data)
64 dictionary[key] = data;
67 /// <summary>
68 /// Deletes the cache item by the specified key.
69 /// </summary>
70 /// <param name="key">The key.</param>
71 public void Delete(string key)
73 dictionary.Remove(key);