public WordTrieNode(WordNodeConfig config, WordTrieNode parent, Word wordToAdd, bool isNodeValue)
     : this(config)
 {
     _parent = parent;
       _word = isNodeValue ? wordToAdd : null;
       _mostPopularWords.Add(wordToAdd);
 }
 public void BuildWithNullTest()
 {
     IEnumerable<Word> words = null;
       var root = new WordTrieNode(_config);
       root.Build(words);
       Assert.IsFalse(root.HasChildNodes);
 }
 public void AddWordWithNullValueTest()
 {
     var root = new WordTrieNode(_config);
       var word = new Word();
       root.Add(word);
       Assert.IsFalse(root.HasChildNodes);
 }
 public void WordsCountTest2()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("aaaa", 111));
       root.Add(new Word("aabb", 222));
       root.Add(new Word("aacc", 333));
       WordTrieNode node = root.Get("aab");
       Assert.AreEqual(node.MostPopularWords.Count(), 1);
 }
 public void WordsLimitTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("aaaa", 333));
       root.Add(new Word("aaba", 111));
       root.Add(new Word("aabc", 333));
       root.Add(new Word("aaca", 222));
       root.Add(new Word("aacb", 333));
       WordTrieNode node = root.Get("aa");
       Assert.AreEqual(node.MostPopularWords.Count(), _config.MostPopularWordsLimit);
 }
 public void BuildTest()
 {
     var words =
     new List<Word>
       {
     new Word("qwe", 111),
     new Word("asd", 222),
     new Word("zxc", 333),
       };
       var root = new WordTrieNode(_config);
       root.Build(words);
       Assert.IsTrue(root.HasChildNodes);
 }
 public void WordsOrberByCountTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("aaaa", 222));
       root.Add(new Word("aabb", 111));
       root.Add(new Word("aabc", 444));
       root.Add(new Word("aaac", 111));
       root.Add(new Word("aacc", 555));
       WordTrieNode node = root.Get("aa");
       IList<Word> words = node.MostPopularWords.ToList();
       Assert.IsTrue(
       words[0].Value.Equals("aacc") &&
       words[1].Value.Equals("aabc") &&
       words[2].Value.Equals("aaaa") &&
       words[3].Value.Equals("aaac")
     );
 }
 public void BuildAfterAddTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("abc", 111));
       root.Add(new Word("def", 111));
       root.Add(new Word("qwe", 111));
       var words =
     new List<Word>
       {
     new Word("qwe", 111),
     new Word("asd", 222),
     new Word("zxc", 333),
       };
       root.Build(words);
       var node1 = root.Get("abc");
       var node2 = root.Get("qwe");
       Assert.IsTrue(node1 == null && node2 != null && node2.Value.Value == "qwe");
 }
 public void ChildNodeNotNullTest1()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("abc", 111));
       var node = root.Get("abc");
       Assert.IsNotNull(node);
 }
 public void AddWordTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("aaa", 111));
       Assert.IsTrue(root.HasChildNodes);
 }
 public void AddNullTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(null);
       Assert.IsFalse(root.HasChildNodes);
 }
 public void ClearTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("abc", 111));
       root.Add(new Word("def", 111));
       root.Add(new Word("qwe", 111));
       root.Clear();
       Assert.IsFalse(root.HasChildNodes);
 }
 public void ClearOnChildNodeTest()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("abc", 111));
       root.Add(new Word("def", 111));
       root.Add(new Word("qwe", 111));
       var node = root.Get("qwe");
       node.Clear();
       Assert.IsTrue(root.HasChildNodes && node.HasValue);
 }
 public void ChildNodeNullTest2()
 {
     var root = new WordTrieNode(_config);
       root.Add(new Word("abc", 111));
       var node = root.Get(string.Empty);
       Assert.IsNull(node);
 }