Example #1
0
        public void GetMostRecentlyUsedEntryReturnsValidEntry(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();

            // Act
            sut.AddEntry(currentLru.Key, currentLru.Entry);
            var actualMru = sut.GetMostRecentlyUsedEntry();
            var actualLru = sut.GetLeastRecentlyUsedEntry();

            // Assert
            actualMru.ShouldBe(currentLru);
            actualLru.ShouldNotBe(currentLru);
        }