public void LatestPopped()
 {
     using (SafeHeapHandleCache cache = new SafeHeapHandleCache(minSize: 5, maxSize: 100, maxHandles: 2))
     {
         var first  = cache.Acquire();
         var second = cache.Acquire();
         cache.Release(first);
         cache.Release(second);
         Assert.Same(second, cache.Acquire());
         Assert.Same(first, cache.Acquire());
     }
 }
 public void OldestPushedOff()
 {
     using (SafeHeapHandleCache cache = new SafeHeapHandleCache(minSize: 5, maxSize: 100, maxHandles: 2))
     {
         var first  = cache.Acquire();
         var second = cache.Acquire();
         var third  = cache.Acquire();
         cache.Release(first);
         cache.Release(second);
         cache.Release(third);
         Assert.True(first.IsClosed);
         Assert.False(second.IsClosed);
         Assert.False(third.IsClosed);
     }
 }
 public void GrabHandleFromEmptyCache()
 {
     using (SafeHeapHandleCache cache = new SafeHeapHandleCache(minSize: 5, maxSize: 100, maxHandles: 2))
     {
         var handle = cache.Acquire();
         Assert.NotNull(handle);
         Assert.Equal((ulong)5, handle.ByteLength);
     }
 }