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"}); }
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"}); }
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"); }