예제 #1
0
        public void ShouldResolveCorrectlyEnumerator()
        {
            var intervalNodeFour  = new IntervalWithValue <long, long>(0, 5, 1);
            var intervalNodeFive  = new IntervalWithValue <long, long>(10, 15, 2);
            var intervalNodeSix   = new IntervalWithValue <long, long>(20, 25, 0);
            var intervalNodeSeven = new IntervalWithValue <long, long>(30, 35, 0);
            var intervalNodeTwo   = new IntervalWithValue <long, long>(5, 10, 1);
            var intervalNodeThree = new IntervalWithValue <long, long>(25, 30, 2);
            var intervalNodeOne   = new IntervalWithValue <long, long>(15, 20, 0);
            var treeIntervals     = new List <IntervalWithValue <long, long> >
            {
                intervalNodeOne, intervalNodeTwo, intervalNodeThree, intervalNodeFour, intervalNodeFive,
                intervalNodeSix, intervalNodeSeven
            };
            var tree = new MutableIntervalBalancedTree <long, long>(treeIntervals);

            using var enumerator = tree.GetEnumerator();
            var enumeratorList = new List <IntervalWithValue <long, long> >();

            while (enumerator.MoveNext())
            {
                enumeratorList.Add(enumerator.Current);
            }
            enumeratorList.Sort();
            treeIntervals.Sort();
            Assert.Equal(treeIntervals, enumeratorList);
        }
예제 #2
0
        public void OnNullRootGetEnumeratorShouldReturnEmptyListEnumerator()
        {
            var tree = new MutableIntervalBalancedTree <long, long>(new List <IntervalWithValue <long, long> >());

            using var enumerator = tree.GetEnumerator();
            Assert.Null(enumerator.Current);
        }