Hi,
I have this CacheManager class which keeps a static dictionary with all sorts of cached data. However, with this dictionary being static it gets filled up with data from the other unit tests. This keeps me from unit testing whether or not the CacheManager is empty on init, and breaks with the principles of unit testing.
Any ideas how to create a proper unit test for this?
Code
public class CacheManager
{
private static readonly Dictionary<ICacheKey, ListCacheItem> cacheEntries =
new Dictionary<ICacheKey, ListCacheItem>();
public static Dictionary<ICacheKey, ListCacheItem> CacheEntries
{
get
{
lock (cacheEntries)
{
return cacheEntries;
}
}
}