public void GetKeysPostOrder_NonEmptyTree_ReturnsCorrectAnswer() { var tree = new AaTree <int>(); tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); tree.GetKeysPostOrder().SequenceEqual(new[] { 1, 3, 2, 5, 7, 10, 9, 8, 6, 4 }) .Should().BeTrue(); }
public void AddRange_MultipleKeys_FormsCorrectTree() { var tree = new AaTree <int>(); tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); tree.Count.Should().Be(10); tree.GetKeysInOrder().SequenceEqual(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }).Should().BeTrue(); tree.GetKeysPostOrder().SequenceEqual(new[] { 1, 3, 2, 5, 7, 10, 9, 8, 6, 4 }).Should().BeTrue(); Validate(tree.Root); }
public void Add_MultipleKeys_FormsCorrectTree() { var tree = new AaTree <int>(); foreach (var elem in new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }) { tree.Add(elem); tree.Count.Should().Be(elem); tree.Contains(elem).Should().BeTrue(); } tree.GetKeysInOrder().SequenceEqual(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }).Should().BeTrue(); tree.GetKeysPostOrder().SequenceEqual(new[] { 1, 3, 2, 5, 7, 10, 9, 8, 6, 4 }).Should().BeTrue(); Validate(tree.Root); }
public void GetKeysPostOrder_EmptyTree_ReturnsCorrectAnswer() { var tree = new AaTree <int>(); tree.GetKeysPostOrder().ToList().Count.Should().Be(0); }