public void Match1_EmptyTrie_DoesNothing() { Word4Trie trie = new Word4Trie(); int count = 0; trie.Match1('a', w => ++ count); Assert.Equal(0, count); }
public void Match1_NoMatch_DoesNothing() { Word4Trie trie = new Word4Trie(); trie.Add(new Word4("bbbb")); int count = 0; trie.Match1('a', w => ++ count); Assert.Equal(0, count); }
public void Match1_NullOnMatch_ThrowsArgumentNull() { Word4Trie trie = new Word4Trie(); Action <Word4> onMatch = null; Exception e = Record.Exception(() => trie.Match1('a', onMatch)); Assert.NotNull(e); ArgumentNullException ane = Assert.IsType <ArgumentNullException>(e); Assert.Equal("onMatch", ane.ParamName); }
public void Match1_WithMatches_ExecutesForEachPrefixMatch() { Word4Trie trie = new Word4Trie(); trie.Add(new Word4("aabc")); trie.Add(new Word4("abcd")); trie.Add(new Word4("bacd")); trie.Add(new Word4("baaa")); List <string> wordsSeen = new List <string>(); trie.Match1('a', w => wordsSeen.Add(w.ToString())); wordsSeen.Sort(); Assert.Equal(2, wordsSeen.Count); Assert.Equal("aabc", wordsSeen[0]); Assert.Equal("abcd", wordsSeen[1]); }