コード例 #1
0
            public void VisitRootNode()
            {
                var trie           = new Trie();
                var sut            = new DepthFirstVisitor();
                var expectedAction = new Mock <Action <Node> >();

                sut.Visit(trie.Root, expectedAction.Object);

                expectedAction.Verify(x => x(trie.Root));
            }
コード例 #2
0
            public void VisitAllNodes()
            {
                var trie = new Trie();

                trie.AddWord("ABER");

                var           sut            = new DepthFirstVisitor();
                var           actual         = new List <Node>();
                Action <Node> expectedAction = x => { actual.Add(x); };

                sut.Visit(trie.Root, expectedAction);

                actual.Select(x => x.Letter).Should().Equal(Trie.RootSymbol, 'A', 'B', 'E', 'R');
            }
コード例 #3
0
            public void VisitChildNodesInAlphabeticalOrder()
            {
                var trie = new Trie();

                trie.AddWord("A");
                trie.AddWord("AB");
                trie.AddWord("AC");
                trie.AddWord("AD");

                var           sut            = new DepthFirstVisitor();
                var           actual         = new List <Node>();
                Action <Node> expectedAction = x => { actual.Add(x); };

                sut.Visit(trie.Root, expectedAction);

                actual.Select(x => x.Letter).Should().Equal(Trie.RootSymbol, 'A', 'B', 'C', 'D');
            }