예제 #1
0
        public void GetEnumerator_WhenEmpty_ThenNoElements()
        {
            // given
            testObject = new DoubleHeap <int>();
            // when
            IEnumerator <int> result = testObject.GetEnumerator();

            // then
            result.MoveNext().Should().BeFalse();
        }
예제 #2
0
        public void GetEnumerator_WhenMultipleElements_ThenFirstMinimumAndLastMaximum()
        {
            // when
            var result = new List <int>();
            IEnumerator <int> enumerator = testObject.GetEnumerator();

            while (enumerator.MoveNext())
            {
                result.Add(enumerator.Current);
            }
            // then
            result.Should().HaveElementAt(0, minimum)
            .And.HaveElementAt(result.Count - 1, maximum);
        }
예제 #3
0
        public void GetEnumerator_WhenSingleElement_ThenThisElementOnly()
        {
            // given
            int element = 17;

            testObject = new DoubleHeap <int>(new[] { element });
            // when
            IEnumerator <int> result = testObject.GetEnumerator();

            // then
            result.MoveNext().Should().BeTrue();
            result.Current.Should().Be(element);
            result.MoveNext().Should().BeFalse();
        }