public void ShouldByNull() { //Arrange var sut = new BuildBinary(); //sut: system under test var array = new int?[] { null }; //Act var head = sut.CreateBinaryTree(array); //Assert Assert.Null(head); }
public void TestCreateBinaryTreeWithNull() { //Arrange var sut = new BuildBinary(); //sut: system under test var array = new int?[] { 1, 2, 3, 4, null, 6, 7, 8, 9 }; //Act var head = sut.CreateBinaryTree(array); //Assert Assert.Equal(1, head.Value); Assert.Equal(2, head.LeftChild.Value); Assert.Equal(3, head.RightChild.Value); }
public void TestCreateBinaryTree() { //Arrange var sut = new BuildBinary(); //sut: system under test var array = new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //Act var head = sut.CreateBinaryTree(array); //Assert Assert.Equal(1, head.Value); Assert.Equal(2, head.LeftChild.Value); Assert.Equal(3, head.RightChild.Value); Assert.Equal(4, head.LeftChild.LeftChild.Value); Assert.Equal(5, head.LeftChild.RightChild.Value); Assert.Equal(6, head.RightChild.LeftChild.Value); Assert.Equal(7, head.RightChild.RightChild.Value); Assert.Equal(8, head.LeftChild.LeftChild.LeftChild.Value); Assert.Equal(9, head.LeftChild.LeftChild.RightChild.Value); Assert.Equal(10, head.LeftChild.RightChild.LeftChild.Value); }