Exemple #1
0
        public void Match2_EmptyTrie_DoesNothing()
        {
            Word4Trie trie  = new Word4Trie();
            int       count = 0;

            trie.Match2('a', 'b', w => ++ count);

            Assert.Equal(0, count);
        }
Exemple #2
0
        public void Match2_NoMatch_DoesNothing()
        {
            Word4Trie trie = new Word4Trie();

            trie.Add(new Word4("bbbb"));
            int count = 0;

            trie.Match2('a', 'b', w => ++ count);

            Assert.Equal(0, count);
        }
Exemple #3
0
        public void Match2_NullAction_ThrowsArgumentNull()
        {
            Word4Trie      trie   = new Word4Trie();
            Action <Word4> action = null;

            Exception e = Record.Exception(() => trie.Match2('a', 'b', action));

            Assert.NotNull(e);
            ArgumentNullException ane = Assert.IsType <ArgumentNullException>(e);

            Assert.Equal("onMatch", ane.ParamName);
        }
Exemple #4
0
        public void Match2_WithMatches_ExecutesForEachPrefixMatch()
        {
            Word4Trie trie = new Word4Trie();

            trie.Add(new Word4("aabc"));
            trie.Add(new Word4("abcd"));
            trie.Add(new Word4("baaa"));
            trie.Add(new Word4("bacd"));
            List <string> wordsSeen = new List <string>();

            trie.Match2('b', 'a', w => wordsSeen.Add(w.ToString()));

            wordsSeen.Sort();
            Assert.Equal(2, wordsSeen.Count);
            Assert.Equal("baaa", wordsSeen[0]);
            Assert.Equal("bacd", wordsSeen[1]);
        }