Exemplo n.º 1
0
        public void SortWords()
        {
            var stream = new MemoryStream(Encoding.UTF8.GetBytes("A, b!\nC."));
            var parser = new TextFileParser();
            var dict = parser.CreateDictionaryFromStream(stream);
            stream = new MemoryStream(Encoding.UTF8.GetBytes("a\nc"));
            var bannWords = parser.CreateDictionaryFromStream(stream);
            var preparer = new SimplePreparer();
            var filteredWords = preparer.GetSortedWords(dict, bannWords);

            CollectionAssert.AreEquivalent(filteredWords.Keys.ToArray(), new string[] {"b"});
        }
Exemplo n.º 2
0
 public void CreateDictionaryFromTextFile()
 {
     var stream = new MemoryStream(Encoding.UTF8.GetBytes("A, b!\nC."));
     var parser = new TextFileParser();
     var dict = parser.CreateDictionaryFromStream(stream);
     CollectionAssert.AreEquivalent(dict.Keys.ToArray(), new string[] {"a", "b", "c"});
 }
Exemplo n.º 3
0
        public void SortWordsInRightOrder()
        {
            var stream = new MemoryStream(Encoding.UTF8.GetBytes("A, b b b!\nC."));
            var parser = new TextFileParser();
            var dict = parser.CreateDictionaryFromStream(stream);
            var preparer = new SimplePreparer();
            var filteredWords = preparer.GetSortedWords(dict, new Dictionary<string, int>());

            CollectionAssert.AreEquivalent(filteredWords.Keys.ToArray()[0], "b");
        }