static void Main(string[] args) { // Instantiate nodes to create tree Node nodeD = new Node(2); Node nodeC = new Node(15); Node nodeB = new Node(5, nodeD); Node nodeA = new Node(3, nodeB, nodeC); // Add root node to FizzBuzz tree FizzBuzzTree fizzbuzzTree = new FizzBuzzTree(nodeA); // Write InOrder list of node values to console Console.WriteLine("InOrder list of FizzBuzz Tree:"); List <Node> fizzBuzzList = fizzbuzzTree.FizzBuzz(); foreach (Node node in fizzBuzzList) { Console.Write($"{node.Value} "); } }
public void FizzBuzz_returns_new_FB_Tree() { // Input: // 4 // 3 5 // 1 2 6 // 10 // 15 // Output: // 4 // Fizz Buzz // 1 2 Fizz // Buzz // FizzBuzz // Arrange BinaryTree <int> tree = new BinaryTree <int>(); // Root tree.Root = new Node <int>(4); // Left of Root tree.Root.Left = new Node <int>(3); tree.Root.Left.Left = new Node <int>(1); tree.Root.Left.Right = new Node <int>(2); // Right of Root tree.Root.Right = new Node <int>(5); tree.Root.Right.Right = new Node <int>(6); tree.Root.Right.Right.Right = new Node <int>(10); tree.Root.Right.Right.Right.Right = new Node <int>(15); // Act BinaryTree <string> resultTree = FizzBuzzTree.FizzBuzz(tree); IEnumerable <string> result = resultTree.Breadth_First(); // Assert string[] expected = new string[] { "4", "Fizz", "Buzz", "1", "2", "Fizz", "Buzz", "FizzBuzz" }; Assert.Equal(expected, result); }