Exemple #1
0
        public void Extract_ShouldExtractAlwaysElementWithBiggestPriorityFromHeap(int[] array, HeapFactory heapFactory, ExtractMethodVerifier extractMethod)
        {
            // Arrange
            var heap = heapFactory(array, _intMaxComparer);

            // Act
            // Assert
            Assert.AreEqual(extractMethod(array), heap.Extract());
        }
Exemple #2
0
        public void TryExtract_WhenThereAreItemsInTheHeap_ShouldExtractTheItemAndReturnTrue(HeapFactory heapFactory, ExtractMethodVerifier verifier)
        {
            // Arrange
            var array = new [] { 1, 2, 3 };
            var heap  = heapFactory(array, _intMaxComparer);

            // Act
            var success = heap.TryExtract(out var maxElement);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(verifier(array), maxElement);
        }