Exemplo n.º 1
0
        public void GetMax_NonEmptyTree_ReturnsCorrectAnswer()
        {
            var tree = new AATree <int>();

            tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            tree.GetMax().Should().Be(10);
        }
Exemplo n.º 2
0
        public void GetMax_NonEmptyTree_ReturnsCorrectAnswer()
        {
            var tree = new AATree <int>();

            tree.AddRange(new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            Assert.AreEqual(10, tree.GetMax());
        }
Exemplo n.º 3
0
        public void Constructor_UseCustomComparer_FormsCorrectTree()
        {
            var tree = new AATree <int>(Comparer <int> .Create((x, y) => y.CompareTo(x)));

            tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            tree.GetMax().Should().Be(1);
            tree.GetMin().Should().Be(10);
            tree.GetKeysInOrder().SequenceEqual(new[] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }).Should().BeTrue();
            Validate(tree.Root);
        }
Exemplo n.º 4
0
        public void Constructor_UseCustomComparer_FormsCorrectTree()
        {
            var tree = new AATree <int>(Comparer <int> .Create((x, y) => y.CompareTo(x)));

            tree.AddRange(new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            Assert.AreEqual(1, tree.GetMax());
            Assert.AreEqual(10, tree.GetMin());

            var expected = new [] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
            var actual   = tree.GetKeysInOrder();

            Assert.IsTrue(Enumerable.SequenceEqual(expected, actual));

            Validate(tree.Root);
        }
Exemplo n.º 5
0
        public void GetMax_EmptyTree_ThrowsCorrectException()
        {
            var tree = new AATree <int>();

            Assert.Throws <InvalidOperationException>(() => tree.GetMax());
        }