public void AddBeyondCapacity() { ConcurrentBoundedSortedCollection<int, string> cbsl = new ConcurrentBoundedSortedCollection<int, string>(3); cbsl.TryAdd(1, "1"); cbsl.TryAdd(5, "5"); cbsl.TryAdd(3, "3"); cbsl.TryAdd(2, "2"); // Should remove "1" cbsl.TryAdd(4, "4"); // Should remove "2" Assert.Equal(cbsl.Capacity, cbsl.Count()); Assert.Equal("3", cbsl.ElementAt(0).Value); Assert.Equal("4", cbsl.ElementAt(1).Value); Assert.Equal("5", cbsl.ElementAt(2).Value); }
public void AddToCapacity() { ConcurrentBoundedSortedCollection<long, int> cbsl = new ConcurrentBoundedSortedCollection<long, int>(4); cbsl.TryAdd(1, 1); cbsl.TryAdd(3, 3); cbsl.TryAdd(-1, -1); cbsl.TryAdd(0, 0); Assert.Equal(4, cbsl.Count()); Assert.Equal(-1, cbsl.ElementAt(0).Value); Assert.Equal(0, cbsl.ElementAt(1).Value); Assert.Equal(1, cbsl.ElementAt(2).Value); Assert.Equal(3, cbsl.ElementAt(3).Value); }