public void adding_duplicate_keys_should_replace_value()
        {
            var cache = new Cache(10);
            cache.Ejector = new LRUCacheEjector(cache);

            string key = "key1";
            string value = "value1";

            cache.Add(key, value);
            cache.Exists(key).ShouldBeTrue();
            cache.Get(key).ShouldEqual(value);

            value = "some new value";
            cache.Add(key,value);
            cache.Get(key).ShouldEqual(value);
        }
        public void AddingDuplicateKeysShouldReplaceValue()
        {
            var cache = new Cache(10);
            cache.Ejector = new RandomEjector(cache);

            const string key = "key1";
            var value = "value1";

            cache.Add(key, value);
            cache.Exists(key).ShouldBeTrue();
            cache.Get(key).ShouldEqual(value);

            value = "some new value";
            cache.Add(key, value);
            cache.Get(key).ShouldEqual(value);
        }
        public void get_should_reset_timestamp()
        {
            var cache = new Cache(3);
            cache.Ejector = new LRUCacheEjector(cache);

            cache.Add("key1", "value1");
            cache.Add("key2", "value2");
            cache.Add("key3", "value3");

            // if we call Get using key1, it becomes youngest
            cache.Get("key1");

            // now when we add one more, the oldest should be removed. Oldest is now key2
            cache.Add("key4", "value4");

            cache.Exists("key1").ShouldBeTrue("key1 should be in cache");
            cache.Exists("key2").ShouldBeFalse("key2 should NOT be in cache");
            cache.Exists("key3").ShouldBeTrue("key3 should be in cache");
            cache.Exists("key4").ShouldBeTrue("key4 should be in cache");
        }