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

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

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

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

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

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

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

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

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

            trie.Add(new Word3("aab"));
            trie.Add(new Word3("aac"));
            trie.Add(new Word3("bac"));
            trie.Add(new Word3("baa"));
            List <string> wordsSeen = new List <string>();

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

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