Example #1
0
 [TestMethod] public void Add_Testing()
 {
     // adding duplicate values should throw exceptions
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>()
         {
             1,
         };
         Assert.ThrowsException <ArgumentException>(() => tree.Add(1));
     }
     // normal add checking
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>()
         {
             1, 2, 3,
         };
         Assert.IsTrue(tree.Count == 3);
         Assert.IsTrue(tree.Contains(1));
         Assert.IsTrue(tree.Contains(2));
         Assert.IsTrue(tree.Contains(3));
     }
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>();
         Stepper.Iterate(100, i => tree.Add(i));
         Assert.IsTrue(tree.Count == 100);
         Stepper.Iterate(100, i => Assert.IsTrue(tree.Contains(i)));
     }
 }
Example #2
0
 [TestMethod] public void TryRemove_Testing()
 {
     // removing a non-existing value should return false
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>()
         {
             1, 3,
         };
         Assert.IsFalse(tree.TryRemove(2));
     }
     // normal remove checking
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>()
         {
             1, 2, 3,
         };
         Assert.IsTrue(tree.Count == 3);
         Assert.IsTrue(tree.TryRemove(1));
         Assert.IsFalse(tree.Contains(1));
         Assert.IsTrue(tree.Count == 2);
         Assert.IsTrue(tree.TryRemove(2));
         Assert.IsFalse(tree.Contains(2));
         Assert.IsTrue(tree.Count == 1);
         Assert.IsTrue(tree.TryRemove(3));
         Assert.IsFalse(tree.Contains(3));
         Assert.IsTrue(tree.Count == 0);
     }
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>();
         Stepper.Iterate(100, i => tree.Add(i));
         Assert.IsTrue(tree.Count == 100);
         Stepper.Iterate(100, i => tree.TryRemove(i));
         Assert.IsTrue(tree.Count == 0);
     }
 }
Example #3
0
        public static void TestAlgorithm(
            Action <int[], Compare <int> > algorithm,
            Action <int[], int, int, Compare <int> > algorithmPartial,
            int?sizeOverride = null)
        {
            void Test(int sizeAdjusted)
            {
                Random random = new Random(randomSeed);

                int[] array = new int[sizeAdjusted];
                Stepper.Iterate(sizeAdjusted, i => array[i] = i);
                Sort.Shuffle(array, random);
                Assert.IsFalse(IsLeastToGreatest(array), "Test failed (invalid randomization).");
                algorithm(array, Compare.Default);
                Assert.IsTrue(IsLeastToGreatest(array), "Sorting algorithm failed.");
            }

            Test(sizeOverride ?? size);             // Even Data Set
            Test((sizeOverride ?? size) + 1);       // Odd Data Set
            if (sizeOverride is null)
            {
                Test(1000); // Large(er) Data Set
            }
            {               // Partial Array Sort
                int[] array = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, };
                watchArray = array;
                algorithmPartial(array, 3, 7, Compare.Default);
                int[] expected = new int[] { 9, 8, 7, /*|*/ 2, 3, 4, 5, 6, /*|*/ 1, 0, };
                for (int i = 0; i < size; i++)
                {
                    Assert.IsTrue(array[i] == expected[i]);
                }
            }
        }
Example #4
0
 [TestMethod] public void TryAdd_Testing()
 {
     // adding duplicate values should return false
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>();
         Assert.IsTrue(tree.TryAdd(1));
         Assert.IsFalse(tree.TryAdd(1));
     }
     // normal add checking
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>();
         Assert.IsTrue(tree.TryAdd(1));
         Assert.IsTrue(tree.TryAdd(2));
         Assert.IsTrue(tree.TryAdd(3));
         Assert.IsTrue(tree.Count == 3);
         Assert.IsTrue(tree.Contains(1));
         Assert.IsTrue(tree.Contains(2));
         Assert.IsTrue(tree.Contains(3));
     }
     {
         IAvlTree <int> tree = new AvlTreeLinked <int>();
         Stepper.Iterate(100, i => tree.TryAdd(i));
         Assert.IsTrue(tree.Count == 100);
         Stepper.Iterate(100, i => Assert.IsTrue(tree.Contains(i)));
     }
 }
Example #5
0
 [TestMethod] public void Remove_Testing()
 {
     // removing a non-existing value should throw exceptions
     {
         IRedBlackTree <int> tree = new RedBlackTreeLinked <int>()
         {
             1, 3,
         };
         Assert.ThrowsException <ArgumentException>(() => tree.Remove(2));
     }
     // normal remove checking
     {
         IRedBlackTree <int> tree = new RedBlackTreeLinked <int>()
         {
             1, 2, 3,
         };
         Assert.IsTrue(tree.Count == 3);
         tree.Remove(1);
         Assert.IsFalse(tree.Contains(1));
         Assert.IsTrue(tree.Count == 2);
         tree.Remove(2);
         Assert.IsFalse(tree.Contains(2));
         Assert.IsTrue(tree.Count == 1);
         tree.Remove(3);
         Assert.IsFalse(tree.Contains(3));
         Assert.IsTrue(tree.Count == 0);
     }
     {
         IRedBlackTree <int> tree = new RedBlackTreeLinked <int>();
         Stepper.Iterate(100, i => tree.Add(i));
         Assert.IsTrue(tree.Count == 100);
         Stepper.Iterate(100, i => tree.Remove(i));
         Assert.IsTrue(tree.Count == 0);
     }
 }
Example #6
0
        public void Iterate_2()
        {
            var evaluator = new Mock <INodeEvaluator>();
            var analyser  = new Mock <IBitAnalyser>();
            var stepper   = new Stepper(evaluator.Object, analyser.Object);

            ushort[] BRANCH_KEYS = new ushort[] {
                // first branch key
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
            };
            const int FIRST_MASK  = 0x1;
            const int SECOND_MASK = 0xfe;
            var       rowTree     = new RowTree
            {
                Branches     = BRANCH_KEYS,
                Instructions = new Instruction[] {
                    new Instruction
                    {
                        Chunk = 0,
                        Mask  = FIRST_MASK,
                    },
                    new Instruction
                    {
                        Chunk = 0,
                        Mask  = SECOND_MASK,
                    },
                },
                Leaves = new int[] {
                    0,
                },
                TestChunks = new TestChunk[] {
                    new TestChunk
                    {
                        KeyOffset  = 0,
                        LeafOffset = 0,
                        LeafLength = 16,
                    }
                },
            };

            ushort value = 100;

            evaluator.Setup(ev => ev.Evaluate(It.IsAny <TestChunk>(), It.IsAny <ushort[]>(), value))
            .Returns(0xfe);

            analyser.Setup(a => a.GetRightmostBit(It.IsAny <uint>()))
            .Returns(0);

            var actual = stepper.Iterate(rowTree, value);

            Assert.AreEqual(0, actual);
            evaluator.Verify(ev => ev.Evaluate(It.IsAny <TestChunk>(), BRANCH_KEYS, value), Times.Once());
            analyser.Verify(a => a.GetRightmostBit(It.IsAny <uint>()), Times.Once());
            analyser.Verify(a => a.GetRightmostBit(SECOND_MASK), Times.Once());

            evaluator.VerifyNoOtherCalls();
            analyser.VerifyNoOtherCalls();
        }
Example #7
0
        [IterationSetup] public void IterationSetup()
        {
            Values = new int[N];
            Stepper.Iterate(N, i => Values[i] = i);
            Random random = new Random(7);

            random.Shuffle(Values);
        }
Example #8
0
File: Sort.cs Project: Thaina/Towel
        [TestMethod] public void Shuffle_Testing()
        {
            Random random = new Random(randomSeed);

            int[] array = new int[size];
            Stepper.Iterate(size, i => array[i] = i);
            Sort.Shuffle(random, array);
            Assert.IsFalse(IsLeastToGreatest(array));
        }
Example #9
0
        public static void Enqueue_Dequeue_Int32_Testing <Queue>()
            where Queue : IQueue <int>, new()
        {
            const int count = 100000;

            int[] values = new int[count];
            Stepper.Iterate(count, i => values[i] = i);
            Enqueue_Dequeue_Testing <int, Queue>(values);
        }
Example #10
0
        public static void Push_Pop_String_Testing <Stack>()
            where Stack : IStack <string>, new()
        {
            const int count = 10000;

            string[] values = new string[count];
            Stepper.Iterate(count, i => values[i] = i.ToString());
            Push_Pop_Testing <string, Stack>(values);
        }
Example #11
0
        public static void Push_Pop_Int32_Testing <Stack>()
            where Stack : IStack <int>, new()
        {
            const int count = 10000;

            int[] values = new int[count];
            Stepper.Iterate(count, i => values[i] = i);
            Push_Pop_Testing <int, Stack>(values);
        }
Example #12
0
        public static void Enqueue_Dequeue_String_Testing <Queue>()
            where Queue : IQueue <string>, new()
        {
            const int count = 100000;

            string[] values = new string[count];
            Stepper.Iterate(count, i => values[i] = i.ToString());
            Enqueue_Dequeue_Testing <string, Queue>(values);
        }
Example #13
0
File: Sort.cs Project: Thaina/Towel
        public static void TestAlgorithm(Action <int[]> algorithm)
        {
            Random random = new Random(randomSeed);

            int[] array = new int[size];
            Stepper.Iterate(size, i => array[i] = i);
            Sort.Shuffle(random, array);
            Assert.IsFalse(IsLeastToGreatest(array));             // make sure the data is randomized before algorithm
            algorithm(array);
            Assert.IsTrue(IsLeastToGreatest(array));
        }
Example #14
0
File: Map.cs Project: Thaina/Towel
        [TestMethod] public void Add_Testing()
        {
            {             // string, int
                const int          count = 100000;
                IMap <string, int> map   = new MapHashLinked <string, int>();
                Stepper.Iterate(count, i => map.Add(i, i.ToString()));
                map.Add(int.MinValue, int.MinValue.ToString());
                map.Add(int.MaxValue, int.MaxValue.ToString());

                // contains
                Stepper.Iterate(count, i => Assert.IsTrue(map.Contains(i)));
                Assert.IsTrue(map.Contains(int.MinValue));
                Assert.IsTrue(map.Contains(int.MaxValue));
                Assert.IsFalse(map.Contains(-1));
                Assert.IsFalse(map.Contains(count));

                // get
                Stepper.Iterate(count, i => Assert.IsTrue(map[i] == i.ToString()));
                Assert.IsTrue(map[int.MinValue] == int.MinValue.ToString());
                Assert.IsTrue(map[int.MaxValue] == int.MaxValue.ToString());

                Assert.ThrowsException <ArgumentException>(() => map.Add(0, 0.ToString()));
                Assert.ThrowsException <ArgumentException>(() => map.Add(int.MinValue, int.MinValue.ToString()));
                Assert.ThrowsException <ArgumentException>(() => map.Add(int.MaxValue, int.MaxValue.ToString()));
            }

            {             // int, string
                const int          count = 100000;
                IMap <int, string> map   = new MapHashLinked <int, string>();
                Stepper.Iterate(count, i => map.Add(i.ToString(), i));
                map.Add(int.MinValue.ToString(), int.MinValue);
                map.Add(int.MaxValue.ToString(), int.MaxValue);

                // contains
                Stepper.Iterate(count, i => Assert.IsTrue(map.Contains(i.ToString())));
                Assert.IsTrue(map.Contains(int.MinValue.ToString()));
                Assert.IsTrue(map.Contains(int.MaxValue.ToString()));
                Assert.IsFalse(map.Contains((-1).ToString()));
                Assert.IsFalse(map.Contains(count.ToString()));

                // get
                Stepper.Iterate(count, i => Assert.IsTrue(map[i.ToString()] == i));
                Assert.IsTrue(map[int.MinValue.ToString()] == int.MinValue);
                Assert.IsTrue(map[int.MaxValue.ToString()] == int.MaxValue);

                Assert.ThrowsException <ArgumentException>(() => map.Add(0.ToString(), 0));
                Assert.ThrowsException <ArgumentException>(() => map.Add(int.MinValue.ToString(), int.MinValue));
                Assert.ThrowsException <ArgumentException>(() => map.Add(int.MaxValue.ToString(), int.MaxValue));
            }
        }
Example #15
0
File: List.cs Project: Thaina/Towel
        [TestMethod] public void Add_Testing()
        {
            const int   count = 100000;
            IList <int> list  = new ListArray <int>();

            Stepper.Iterate(count, i => list.Add(i));

            // check count
            Assert.IsTrue(list.Count == count);

            // check for all values
            bool[] values = new bool[count];
            list.Stepper(i => values[i] = true);
            values.Stepper(b => Assert.IsTrue(b));
        }
Example #16
0
File: Map.cs Project: Thaina/Towel
        [TestMethod] public void Remove_Testing()
        {
            {             // string, int
                const int          count = 100000;
                IMap <string, int> map   = new MapHashLinked <string, int>();
                Stepper.Iterate(count, i => map.Add(i, i.ToString()));
                for (int i = 0; i < count; i += 3)
                {
                    map.Remove(i);
                }
                for (int i = 0; i < count; i++)
                {
                    if (i % 3 == 0)
                    {
                        Assert.IsFalse(map.Contains(i));
                    }
                    else
                    {
                        Assert.IsTrue(map.Contains(i));
                    }
                }
                Assert.IsFalse(map.Contains(-1));
                Assert.IsFalse(map.Contains(count));
            }

            {             // int, string
                const int          count = 100000;
                IMap <int, string> map   = new MapHashLinked <int, string>();
                Stepper.Iterate(count, i => map.Add(i.ToString(), i));
                for (int i = 0; i < count; i += 3)
                {
                    map.Remove(i.ToString());
                }
                for (int i = 0; i < count; i++)
                {
                    if (i % 3 == 0)
                    {
                        Assert.IsFalse(map.Contains(i.ToString()));
                    }
                    else
                    {
                        Assert.IsTrue(map.Contains(i.ToString()));
                    }
                }
                Assert.IsFalse(map.Contains((-1).ToString()));
                Assert.IsFalse(map.Contains(count.ToString()));
            }
        }
Example #17
0
        [TestMethod] public void Remove_Testing()
        {
            {             // int
                const int  count = 100000;
                ISet <int> set   = new SetHashLinked <int>();
                Stepper.Iterate(count, i => set.Add(i));
                for (int i = 0; i < count; i += 3)
                {
                    set.Remove(i);
                }
                for (int i = 0; i < count; i++)
                {
                    if (i % 3 == 0)
                    {
                        Assert.IsFalse(set.Contains(i));
                    }
                    else
                    {
                        Assert.IsTrue(set.Contains(i));
                    }
                }
                Assert.IsFalse(set.Contains(-1));
                Assert.IsFalse(set.Contains(count));
            }

            {             // string
                const int     count = 100000;
                ISet <string> set   = new SetHashLinked <string>();
                Stepper.Iterate(count, i => set.Add(i.ToString()));
                for (int i = 0; i < count; i += 3)
                {
                    set.Remove(i.ToString());
                }
                for (int i = 0; i < count; i++)
                {
                    if (i % 3 == 0)
                    {
                        Assert.IsFalse(set.Contains(i.ToString()));
                    }
                    else
                    {
                        Assert.IsTrue(set.Contains(i.ToString()));
                    }
                }
                Assert.IsFalse(set.Contains((-1).ToString()));
                Assert.IsFalse(set.Contains(count.ToString()));
            }
        }
Example #18
0
File: List.cs Project: Thaina/Towel
        [TestMethod] public void Remove_Testing()
        {
            const int   count = 1000;
            IList <int> list  = new ListArray <int>();

            Stepper.Iterate(count, i => list.Add(i));

            // check count
            Assert.IsTrue(list.Count == count);

            // check for all values
            bool[] values = new bool[count];
            list.Stepper(i => values[i] = true);
            values.Stepper(b => Assert.IsTrue(b));

            // remove every 3rd value
            Stepper.Iterate(count / 3 + 1, i => list.RemoveFirst(i * 3));
            Array.Fill(values, false);
            list.Stepper(i => values[i] = true);
            for (int i = 0; i < count; i++)
            {
                Assert.IsTrue(i % 3 == 0 ? !values[i] : values[i]);
            }

            // check count
            Assert.IsTrue(list.Count == count / 3 * 2);

            // remove the remaining values
            for (int i = 0; i < count; i++)
            {
                if (values[i])
                {
                    list.RemoveFirst(i);
                }
            }
            Array.Fill(values, false);
            list.Stepper(i => values[i] = true);
            values.Stepper(b => Assert.IsFalse(b));

            // check count
            Assert.IsTrue(list.Count == 0);

            // exception
            Assert.ThrowsException <ArgumentException>(() => list.RemoveFirst(0));
        }
Example #19
0
        [TestMethod] public void Dequeue_Testing()
        {
            void Test <T>(T[] values, Compare <T> compare)
            {
                T[] clonedValues = (T[])values.Clone();
                Towel.Sort.Shuffle(clonedValues);
                IHeap <T> heap = new HeapArray <T>(compare);

                clonedValues.Stepper(x => heap.Enqueue(x));
                foreach (T value in values)
                {
                    T dequeue = heap.Dequeue();
                    Assert.IsTrue(value.Equals(dequeue));
                }
            }

            {             // int compare
                const int count  = 100;
                int[]     values = new int[count];
                Stepper.Iterate(count, i => values[i] = i);
                Array.Sort(values, (a, b) => - a.CompareTo(b));
                Test(values, (a, b) => Compare.Wrap(a.CompareTo(b)));
            }
            {             // string compare
                const int count  = 100;
                string[]  values = new string[count];
                Stepper.Iterate(count, i => values[i] = i.ToString());
                Array.Sort(values, (a, b) => - a.CompareTo(b));
                Test(values, (a, b) => Compare.Wrap(a.CompareTo(b)));
            }
            {             // int reverse compare
                const int count  = 100;
                int[]     values = new int[count];
                Stepper.Iterate(count, i => values[i] = i);
                Array.Sort(values);
                Test(values, (a, b) => Compare.Wrap(-a.CompareTo(b)));
            }
            {             // string reverse compare
                const int count  = 100;
                string[]  values = new string[count];
                Stepper.Iterate(count, i => values[i] = i.ToString());
                Array.Sort(values);
                Test(values, (a, b) => Compare.Wrap(-a.CompareTo(b)));
            }
        }
Example #20
0
File: Map.cs Project: Thaina/Towel
        [TestMethod] public void Set_Testing()
        {
            {             // string, int
                const int          count = 100000;
                IMap <string, int> map   = new MapHashLinked <string, int>();
                Stepper.Iterate(count, i => map[i] = i.ToString());
                map[int.MinValue] = int.MinValue.ToString();
                map[int.MaxValue] = int.MaxValue.ToString();

                // contains
                Stepper.Iterate(count, i => Assert.IsTrue(map.Contains(i)));
                Assert.IsTrue(map.Contains(int.MinValue));
                Assert.IsTrue(map.Contains(int.MaxValue));
                Assert.IsFalse(map.Contains(-1));
                Assert.IsFalse(map.Contains(count));

                // get
                Stepper.Iterate(count, i => Assert.IsTrue(map[i] == i.ToString()));
                Assert.IsTrue(map[int.MinValue] == int.MinValue.ToString());
                Assert.IsTrue(map[int.MaxValue] == int.MaxValue.ToString());
            }

            {             // int, string
                const int          count = 100000;
                IMap <int, string> map   = new MapHashLinked <int, string>();
                Stepper.Iterate(count, i => map[i.ToString()] = i);
                map[int.MinValue.ToString()] = int.MinValue;
                map[int.MaxValue.ToString()] = int.MaxValue;

                // contains
                Stepper.Iterate(count, i => Assert.IsTrue(map.Contains(i.ToString())));
                Assert.IsTrue(map.Contains(int.MinValue.ToString()));
                Assert.IsTrue(map.Contains(int.MaxValue.ToString()));
                Assert.IsFalse(map.Contains((-1).ToString()));
                Assert.IsFalse(map.Contains(count.ToString()));

                // get
                Stepper.Iterate(count, i => Assert.IsTrue(map[i.ToString()] == i));
                Assert.IsTrue(map[int.MinValue.ToString()] == int.MinValue);
                Assert.IsTrue(map[int.MaxValue.ToString()] == int.MaxValue);
            }
        }
Example #21
0
        [TestMethod] public void Add_Testing()
        {
            {             // int
                const int  count = 100000;
                ISet <int> set   = new SetHashLinked <int>();
                Stepper.Iterate(count, i => set.Add(i));
                set.Add(int.MinValue);
                set.Add(int.MaxValue);

                Stepper.Iterate(count, i => Assert.IsTrue(set.Contains(i)));
                Assert.IsTrue(set.Contains(int.MinValue));
                Assert.IsTrue(set.Contains(int.MaxValue));
                Assert.IsFalse(set.Contains(-1));
                Assert.IsFalse(set.Contains(count));

                Assert.ThrowsException <ArgumentException>(() => set.Add(0));
                Assert.ThrowsException <ArgumentException>(() => set.Add(int.MinValue));
                Assert.ThrowsException <ArgumentException>(() => set.Add(int.MaxValue));
            }

            {             // string
                const int     count = 100000;
                ISet <string> set   = new SetHashLinked <string>();
                Stepper.Iterate(count, i => set.Add(i.ToString()));
                set.Add(int.MinValue.ToString());
                set.Add(int.MaxValue.ToString());

                Stepper.Iterate(count, i => Assert.IsTrue(set.Contains(i.ToString())));
                Assert.IsTrue(set.Contains(int.MinValue.ToString()));
                Assert.IsTrue(set.Contains(int.MaxValue.ToString()));
                Assert.IsFalse(set.Contains((-1).ToString()));
                Assert.IsFalse(set.Contains(count.ToString()));

                Assert.ThrowsException <ArgumentException>(() => set.Add(0.ToString()));
                Assert.ThrowsException <ArgumentException>(() => set.Add(int.MinValue.ToString()));
                Assert.ThrowsException <ArgumentException>(() => set.Add(int.MaxValue.ToString()));
            }
        }
Example #22
0
        public void Iterate_0()
        {
            var evaluator = new Mock <INodeEvaluator>();
            var analyser  = new Mock <IBitAnalyser>();
            var stepper   = new Stepper(evaluator.Object, analyser.Object);

            var rowTree = new RowTree {
                Branches     = new ushort[] { },
                Instructions = new Instruction[] { },
                Leaves       = new int[] { },
                TestChunks   = new TestChunk[] { },
            };

            ushort value = 100;

            var actual = stepper.Iterate(rowTree, value);

            Assert.AreEqual(-1, actual);
            evaluator.Verify(ev => ev.Evaluate(It.IsAny <TestChunk>(), It.IsAny <ushort[]>(), value), Times.Never());
            analyser.Verify(a => a.GetRightmostBit(It.IsAny <uint>()), Times.Never());

            evaluator.VerifyNoOtherCalls();
            analyser.VerifyNoOtherCalls();
        }
Example #23
0
        [TestMethod] public void Remove_Testing()
        {
            // removing a non-existing value should throw exceptions
            {
                IAvlTree <int> tree = new AvlTreeLinked <int>()
                {
                    1, 3,
                };
                Assert.ThrowsException <ArgumentException>(() => tree.Remove(2));
            }
            // normal remove checking
            {
                IAvlTree <int> tree = new AvlTreeLinked <int>()
                {
                    1, 2, 3,
                };
                Assert.IsTrue(tree.Count == 3);
                tree.Remove(1);
                Assert.IsFalse(tree.Contains(1));
                Assert.IsTrue(tree.Count == 2);
                tree.Remove(2);
                Assert.IsFalse(tree.Contains(2));
                Assert.IsTrue(tree.Count == 1);
                tree.Remove(3);
                Assert.IsFalse(tree.Contains(3));
                Assert.IsTrue(tree.Count == 0);
            }
            {
                IAvlTree <int> tree = new AvlTreeLinked <int>();
                Stepper.Iterate(100, i => tree.Add(i));
                Assert.IsTrue(tree.Count == 100);
                Stepper.Iterate(100, i => tree.Remove(i));
                Assert.IsTrue(tree.Count == 0);
            }
            // large randomized data set
            {
                const int      count = 1000;
                IAvlTree <int> tree  = new AvlTreeLinked <int>();
                for (int i = 0; i < count; i++)
                {
                    Assert.IsTrue(tree.Count == i);
                    tree.Add(i);
                    Assert.IsTrue(tree.Count == i + 1);
                    Assert.IsTrue(tree.Contains(i));

                    int stepperCount = 0;
                    tree.Stepper(x => stepperCount++);
                    Assert.IsTrue(stepperCount == tree.Count);
                }
                int[] values = new int[count];
                for (int i = 0; i < count; i++)
                {
                    values[i] = i;
                }
                Random random = new Random(7);
                random.Shuffle(values);
                for (int i = 0; i < count; i++)
                {
                    Assert.IsTrue(tree.Count == count - i);
                    tree.Remove(values[i]);
                    Assert.IsTrue(tree.Count == count - i - 1);
                    Assert.IsFalse(tree.Contains(values[i]));

                    int stepperCount = 0;
                    tree.Stepper(x => stepperCount++);
                    Assert.IsTrue(stepperCount == tree.Count);
                }
            }
        }