Пример #1
0
		public void RemoveEmpty()
		{
			int size = 10;
			IDictionary cache = new LRUMap(size);

			cache.Remove("key:" + 1);
		}
Пример #2
0
		public void PutAndRemove()
		{
			int size = 10;
			IDictionary cache = new LRUMap(size);

			cache.Add("key:" + 1, "data:" + 1);
			cache.Remove("key:" + 1);
			Assert.IsNull(cache["key:" + 1]);
		}
Пример #3
0
		public void IndexerDoesBoundsChecking()
		{
			var map = new LRUMap(128);

			for (int i = 0; i < 200; i++)
				map["str" + i] = i;

			Assert.That(map.Count, Is.EqualTo(128));
		}
Пример #4
0
		public void AddDoesBoundsChecking()
		{
			var map = new LRUMap(128);

			for (int i = 0; i < 200; i++)
				map.Add("str" + i, i);

			Assert.That(map.Count, Is.EqualTo(128));
		}
Пример #5
0
		public void PutWithNoSizeLimit()
		{
			int size = 10;
			IDictionary cache = new LRUMap();

			for (int i = 0; i < size; i++)
			{
				cache.Add("key:" + i, "data:" + i);
			}

			for (int i = 0; i < size; i++)
			{
				string data = (string)cache["key:" + i];
				Assert.AreEqual("data:" + i, data, "Data is wrong.");
			}
		}
Пример #6
0
		public void GetEntrySet()
		{
			int size = 10;
			IDictionary cache = new LRUMap(size);

			for (int i = 0; i < size; i++)
			{
				cache.Add("key:" + i, "data:" + i);
			}
			Assert.AreEqual(size, cache.Keys.Count, "Set contains the wrong number of items.");

			// check minimal correctness
			foreach (DictionaryEntry entry in cache)
			{
				Assert.AreNotEqual(-1, entry.Value.ToString().IndexOf("data:"));
			}
		}
		void IDeserializationCallback.OnDeserialization(object sender)
		{
			strongReferenceCache = new LRUMap(strongReferenceCount);
		}
		public SoftLimitMRUCache(int strongReferenceCount)
		{
			this.strongReferenceCount = strongReferenceCount;
			strongReferenceCache = new LRUMap(strongReferenceCount);
		}
Пример #9
0
		public void PutWithSizeLimitOfZero()
		{
			IDictionary cache = new LRUMap(0);

			cache.Add("key", "data");

			string data = (string)cache["key"];
			Assert.IsNull(data, "Data is wrong.");
		}
Пример #10
0
 void IDeserializationCallback.OnDeserialization(object sender)
 {
     strongReferenceCache = new LRUMap(strongReferenceCount);
 }
Пример #11
0
 public SoftLimitMRUCache(int strongReferenceCount)
 {
     this.strongReferenceCount = strongReferenceCount;
     strongReferenceCache      = new LRUMap(strongReferenceCount);
 }
Пример #12
0
		public SimpleMRUCache(int strongReferenceCount)
		{
			this.strongReferenceCount = strongReferenceCount;
			cache = new LRUMap(strongReferenceCount);
		}
Пример #13
0
 public SimpleMRUCache(int strongReferenceCount)
 {
     this.strongReferenceCount = strongReferenceCount;
     cache = new LRUMap(strongReferenceCount);
 }