public void Trim() { var target = new ConcurrentPriorityQueue <string, int>(2); int expectedCapacity = target.Capacity; for (var i = 0; i < 10; i++) { if (target.Count == target.Capacity) { expectedCapacity = expectedCapacity * ConcurrentPriorityQueue <string, int> ._resizeFactor; } target.Enqueue("a", i); } Assert.AreEqual(expectedCapacity, target.Capacity); string items = string.Join(",", target); target.Trim(); Assert.AreEqual(10, target.Capacity); Assert.AreEqual(items, string.Join(",", target)); }