diff --git a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruSoakTests.cs b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruSoakTests.cs index 6d43f4f4..4acf673d 100644 --- a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruSoakTests.cs +++ b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruSoakTests.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using BitFaster.Caching.Lru; using FluentAssertions; @@ -189,6 +190,26 @@ await Threaded.Run(4, () => { } } + [Fact] + public async Task WhenAddingCacheSizeItemsNothingIsEvicted() + { + const int size = 1024; + + var cache = new ConcurrentLruBuilder() + .WithMetrics() + .WithCapacity(size) + .Build(); + + await Threaded.Run(4, () => + { + for (int i = 0; i < size; i++) + { + cache.GetOrAdd(i, k => k); + } + }); + + cache.Metrics.Value.Evicted.Should().Be(0); + } private void RunIntegrityCheck() { new ConcurrentLruIntegrityChecker, LruPolicy, TelemetryPolicy>(this.lru).Validate();