public void LruCache_Contains()
 {
     LruCache<int, string> cache = new LruCache<int, string>(2);
     cache.Put(1, "One");
     cache.Put(2, "Two");
     Assert.IsTrue(cache.Contains(1));
     Assert.IsTrue(cache.Contains(2));
     Assert.IsFalse(cache.Contains(3));
 }
Esempio n. 2
0
        public void TestLru_Contains()
        {
            var l = new LruCache <int, int>(2, null, logger);

            l.Add(1, 1);

            l.Add(2, 2);

            Assert.True(l.Contains(1), "1 should be contained");

            l.Add(3, 3);

            Assert.False(l.Contains(1), "Contains should not have updated recent-ness of 1");
        }
Esempio n. 3
0
        public void ContainsKeyValuePairNotFound()
        {
            var cache = new LruCache <int, int>(10);

            for (int index = 0; index < 10; ++index)
            {
                cache.Add(new KeyValuePair <int, int>(index, index));
            }

            bool found = cache.Contains(new KeyValuePair <int, int>(11, 12));

            Assert.IsFalse(found, "Item not should have been found");
        }
Esempio n. 4
0
        public void ContainsKeyValuePair()
        {
            var cache = new LruCache <int, int>(10);

            for (int index = 0; index < 10; ++index)
            {
                cache.Add(new KeyValuePair <int, int>(index, index));
            }

            bool found = cache.Contains(new KeyValuePair <int, int>(0, 0));

            Assert.IsTrue(found, "Item should have been found");
        }
Esempio n. 5
0
        public void TestLru_Peek()
        {
            var l = new LruCache <int, int>(2, null, logger);

            l.Add(1, 1);

            l.Add(2, 2);

            var(v, res) = l.Peek(1);

            Assert.True(res);
            Assert.Equal(1, v);

            l.Add(3, 3);

            Assert.False(l.Contains(1), "should not have updated recent-ness of 1");
        }
        public void Contains_EntryExists_ReturnsTrue()
        {
            var lru = new LruCache<string, string>(1);
            lru.Add("k1", "v1");

            var entry = new KeyValuePair<string, string>("k1", "v1");

            Assert.IsTrue(lru.Contains(entry));
        }
        public void Contains_EntryDoesNotExist_ReturnsFalse()
        {
            var lru = new LruCache<string, string>(1);

            var entry = new KeyValuePair<string, string>("k1", "v1");

            Assert.IsFalse(lru.Contains(entry));
        }
Esempio n. 8
0
 public bool IsUnlocked(Address address) => _unlockedAccounts.Contains(address.ToString());