Example #1
0
        public void AddingNewItemGivenCacheFullShouldRemoveLru(Fixture fixture, LeastRecentlyUsedCache <int, string> sut)
        {
            // Arrange
            for (int i = 0; i < sut.Capacity; i++)
            {
                var key = fixture.Create <int>();
                sut.AddEntry(key, fixture.Create <string>());
            }

            var currentLru = sut.GetLeastRecentlyUsedEntry();
            var newKey     = fixture.Create <int>();
            var newValue   = fixture.Create <string>();

            // Act
            sut.AddEntry(newKey, newValue);
            var actual = sut.ContainsKey(currentLru.Key);

            // Assert
            actual.ShouldBeFalse();
        }