Example #1
0
        public void CanGetEntry()
        {
            var sut = new Lfu(1);

            sut.Add(1, "Test");

            Assert.Equal("Test", sut.Get(1));
        }
Example #2
0
        public void Fuzzy()
        {
            var testCaseSize = 10;
            var sut          = new Lfu(testCaseSize);

            for (var i = 0; i < testCaseSize - 1; i++)
            {
                sut.Add(i, i.ToString(CultureInfo.InvariantCulture));
            }

            sut.Add(testCaseSize, testCaseSize.ToString(CultureInfo.InvariantCulture));

            for (var i = testCaseSize + 1; i < testCaseSize * 2; i++)
            {
                for (var j = 0; j < testCaseSize; j++)
                {
                    sut.Get(j);
                }

                sut.Add(i, i.ToString(CultureInfo.InvariantCulture));

                Assert.Null(sut.Get(i - testCaseSize - 1));
            }
        }