public void WhenLookupCachedItem_ThenItemIsReturned()
        {
            var cache = new LeastRecentlyUsedCache <string, string>(2);

            cache.Add("one", "ONE");
            cache.Add("two", "TWO");

            Assert.AreEqual("ONE", cache.Lookup("one"));
            Assert.AreEqual("TWO", cache.Lookup("two"));
        }
        public void WhenItemAddedTwice_ThenSecondCallIsIgnored()
        {
            var cache = new LeastRecentlyUsedCache <string, string>(2);

            cache.Add("one", "ONE");
            cache.Add("one", "ONE");
            cache.Add("two", "TWO");

            Assert.AreEqual("ONE", cache.Lookup("one"));
            Assert.AreEqual("TWO", cache.Lookup("two"));
        }
        public void WhenAddingItemsBeyondCapacity_ThenLeastReentlyUsedItemIsPurged()
        {
            var cache = new LeastRecentlyUsedCache <string, string>(2);

            cache.Add("one", "ONE");
            cache.Add("two", "TWO");
            cache.Add("three", "THREE");

            Assert.IsNull(cache.Lookup("one"));
            Assert.AreEqual("TWO", cache.Lookup("two"));
            Assert.AreEqual("THREE", cache.Lookup("three"));
        }
        public void WhenLookingUpItem_ThenItemIsMarkedAsUsed()
        {
            var cache = new LeastRecentlyUsedCache <string, string>(2);

            cache.Add("one", "ONE");
            cache.Add("two", "TWO");
            cache.Lookup("one");
            cache.Add("three", "THREE");

            Assert.IsNull(cache.Lookup("two"));
            Assert.AreEqual("ONE", cache.Lookup("one"));
            Assert.AreEqual("THREE", cache.Lookup("three"));
        }
        public void WhenItemExists_ThenRemoveSucceeds()
        {
            var cache = new LeastRecentlyUsedCache <string, string>(2);

            cache.Add("one", "ONE");
            cache.Remove("one");
            cache.Remove("doesnotexist");

            Assert.IsNull(cache.Lookup("one"));
        }