Exemplo n.º 1
0
        public void LeasttRecentlyUsedCacheClearEmptiesCache()
        {
            const int expectedCount = 0;

            var cache = new LeastRecentlyUsedCache <int, TestCacheStub>(5);

            cache.Insert(1, new TestCacheStub {
                Id = 1, Value = 1.1
            });
            cache.Insert(2, new TestCacheStub {
                Id = 2, Value = 1.2
            });
            cache.Insert(3, new TestCacheStub {
                Id = 3, Value = 1.3
            });
            cache.Insert(4, new TestCacheStub {
                Id = 4, Value = 1.4
            });
            cache.Insert(5, new TestCacheStub {
                Id = 5, Value = 1.5
            });

            cache.Clear();

            Assert.AreEqual(expectedCount, cache.Count);
        }
Exemplo n.º 2
0
        public void ClearShouldRemoveAllData(int[] keys, string[] entries, LeastRecentlyUsedCache <int, string> sut)
        {
            // Arrange
            for (int i = 0; i < keys.Length; i++)
            {
                sut.AddEntry(keys[i], entries[i]);
            }

            // Act
            sut.Clear();
            var actual = sut.Count;

            // Assert
            actual.ShouldBe(0);
        }