Exemplo n.º 1
0
        public void ShouldPrintLinkedList()
        {
            var expectedOutputs = new List <int>()
            {
                1, 2, 3
            };
            IConsoleWriter writerMock = MockWriter.GetInstance(expectedOutputs);

            LinkedListDS linkedList = GetLinkedList(writerMock);

            linkedList.Result();
        }
Exemplo n.º 2
0
        public void ShouldPrintTreeNodesInZigZagTraversal()
        {
            var expectedOutputs = new List <int>()
            {
                1, 3, 2, 4, 5, 6
            };
            IConsoleWriter  writerMock      = MockWriter.GetInstance(expectedOutputs);
            TreeDSNode      rootNode        = TreeTestData.GetSimpleTreeRootNode();
            ZigZagTraversal zigzagTraversal = new ZigZagTraversal(rootNode, writerMock);

            zigzagTraversal.Travel();
        }
        public void ShouldPrintTreeInLevelOrderForComplexTree()
        {
            var expectedOutputs = new List <int>()
            {
                8, 7, 6, 5, 4, 3, 2, 1
            };
            IConsoleWriter writerMock = MockWriter.GetInstance(expectedOutputs);
            var            rootNode   = TreeTestData.GetComplexTreeRootNode();
            var            levelOrderTraversalInReverse = new LevelOrderTraversalInReverse(writerMock);

            levelOrderTraversalInReverse.Print(rootNode);
        }
Exemplo n.º 4
0
        public void ShouldPrintTreeInLevelOrder()
        {
            var expectedOutputs = new List <int>()
            {
                1, 2, 3, 4, 5, 6
            };
            IConsoleWriter writerMock = MockWriter.GetInstance(expectedOutputs);
            TreeDSNode     rootNode   = TreeTestData.GetSimpleTreeRootNode();
            TreeTraversal  tree       = new TreeTraversal(rootNode, writerMock);

            tree.LevelOrderTraversal();
        }
Exemplo n.º 5
0
        public void ShouldAddNodeAfterGivenValue()
        {
            var expectedOutputs = new List <int>()
            {
                1, 2, 4, 3
            };
            IConsoleWriter writerMock = MockWriter.GetInstance(expectedOutputs);

            LinkedListDS linkedList = GetLinkedList(writerMock);

            linkedList.AddNodeAfter(2, 4);

            linkedList.Result();
        }