Beispiel #1
0
        public void Match2_EmptyTrie_DoesNothing()
        {
            Word3Trie trie  = new Word3Trie();
            int       count = 0;

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

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

            trie.Add(new Word3("bbb"));
            int count = 0;

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

            Assert.Equal(0, count);
        }
Beispiel #3
0
        public void Match2_NullOnMatch_ThrowsArgumentNull()
        {
            Word3Trie      trie    = new Word3Trie();
            Action <Word3> onMatch = null;

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

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

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

            trie.Add(new Word3("aab"));
            trie.Add(new Word3("abc"));
            trie.Add(new Word3("aba"));
            trie.Add(new Word3("bbc"));
            trie.Add(new Word3("baa"));
            List <string> wordsSeen = new List <string>();

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

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