public void LeastRecentlyUsedEntryRemoved() { var sut = new Lru(1); sut.Add(1, "Test"); sut.Add(2, "Test1"); Assert.Null(sut.Get(1)); Assert.Equal("Test1", sut.Get(2)); }
public static void Test() { var cache = new Lru <string, int?>(3); cache.Set("a", 1); cache.Set("a", 2); cache.Set("b", 3); cache.Set("c", 4); Console.WriteLine("a={0}, b={1}, c={2}", cache.Get("a"), cache.Get("b"), cache.Get("c")); cache.Set("d", 5); Console.WriteLine("a={0}, b={1}, c={2}, d={3}", cache.Get("a"), cache.Get("b"), cache.Get("c"), cache.Get("d")); }
public void CanGetEntry() { var sut = new Lru(1); sut.Add(1, "Test"); Assert.Equal("Test", sut.Get(1)); }
public void Fuzzy() { const int testCaseSize = 1000; var sut = new Lru(testCaseSize); for (var i = 0; i < testCaseSize; i++) { sut.Add(i, i.ToString(CultureInfo.InvariantCulture)); } for (var i = testCaseSize; i < testCaseSize * 2; i++) { sut.Add(i, i.ToString(CultureInfo.InvariantCulture)); Assert.Null(sut.Get(i - testCaseSize)); } }