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); }
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()); }
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); }
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); }
public void GetMax_EmptyTree_ThrowsCorrectException() { var tree = new AATree <int>(); Assert.Throws <InvalidOperationException>(() => tree.GetMax()); }