Пример #1
0
        public void AddSomeValue_RemoveIt_ItemMustRemoved()
        {
            var lru = new LruCacher <int, string>(2);

            lru.Add(1, "a");
            lru.Add(2, "b");
            var val = lru.Remove(1, out var v);

            Assert.IsTrue(val);
            Assert.AreEqual(v, "a");
            Assert.AreEqual(1, lru.Count);
            val = lru.Remove(99, out v);
            Assert.IsFalse(val);
            Assert.IsNull(v);
        }
Пример #2
0
        public void AddSomeValue_RemoveItem_RemovedEventMustBeFired()
        {
            var lru = new LruCacher <int, string>(2);

            lru.Add(1, "a");
            int    rk = default;
            string rv = default;

            lru.Removed += (a, b) =>
            {
                rk = a;
                rv = b;
            };
            lru.Remove(1, out _);
            Assert.AreEqual(1, rk);
            Assert.AreEqual("a", rv);
        }