public void RemoveBy_Odd_OnlyEvenShouldStay() { var heap = new HeapOverList <int>(); heap.AddRange(new[] { 5, 8, 6, 3, 1, 5, 8, 6, 9, 9, 2 }); var initCount = heap.Count; var removedCount = heap.RemoveBy(item => item % 2 == 1); removedCount.Should().Be(initCount - heap.Count); heap._storage.Should().BeInAscendingOrder(); heap._storage.Should().Contain(item => item % 2 == 0); }
public void RemoveMin_ShouldReturnMinElement_DecreaseAmountByOne() { var heap = new HeapOverList <int>(); heap.AddRange(new[] { 5, 8, 6, 3, 1, 5, 8, 6, 9, 9, 2 }); var initMin = heap.Min; var initCount = heap.Count; var removedMin = heap.RemoveMin(); initMin.Should().Be(removedMin); heap.Count.Should().Be(initCount - 1); initMin.Should().BeLessOrEqualTo(heap.Min); heap._storage.Should().BeInAscendingOrder(); }
public void RemoveAtMiddle_ShouldReturnMiddleElement_DecreaseAmountByOne() { var heap = new HeapOverList <int>(); heap.AddRange(new[] { 5, 8, 6, 3, 1, 5, 8, 6, 9, 9, 2 }); var initMin = heap.Min; var initCount = heap.Count; var removedItem = heap.RemoveAt(heap.Count / 2); Console.WriteLine($"removed item {removedItem}"); initMin.Should().Be(heap.Min); heap.Count.Should().Be(initCount - 1); heap._storage.Should().BeInAscendingOrder(); }