Beispiel #1
0
        public void SeeAllAnagramsInFile()
        {
            ReadFile file      = new ReadFile();
            var      wordsList = file.ReadWordsFromFile("words list.txt");

            AnagramWorker anagramWorker = new AnagramWorker();

            anagramWorker.SetList(wordsList);
            var allAnagrams = anagramWorker.FindAllAnagrams();
        }
Beispiel #2
0
        public void FindMostLengthAnagramsInAnagramsListTest()
        {
            AnagramWorker anagram = new AnagramWorker();

            anagram.SetList(GetTestWordsList());

            List <List <String> > anagramsList = anagram.FindAllAnagrams();

            var mostLengthanagrams = anagram.FindMostLengthAnagramsInAnagramsList(anagramsList);

            Assert.AreEqual("parsley", mostLengthanagrams[0]);
        }
Beispiel #3
0
        public void SearchAllAnagramsInWordListTest()
        {
            AnagramWorker anagram = new AnagramWorker();

            anagram.SetList(GetTestWordsList());

            List <List <String> > anagramsList = anagram.FindAllAnagrams();

            Assert.AreEqual(4, anagramsList.Count);
            Assert.AreEqual(4, anagramsList[0].Count);
            Assert.AreEqual(1, anagramsList[1].Count);
            Assert.AreEqual(3, anagramsList[2].Count);
            Assert.AreEqual(1, anagramsList[3].Count);
        }
Beispiel #4
0
        public void SearchAnagramInWordListOnWordTest()
        {
            AnagramWorker anagram = new AnagramWorker();

            String        testWord = "parsley";
            List <String> words    = GetTestWordsList();

            anagram.SetList(words);
            List <String> anagrams = anagram.FindOnWord(testWord);

            Assert.AreEqual(4, anagrams.Count);

            Assert.AreEqual(true, anagrams.Contains("players"));
            Assert.AreEqual(true, anagrams.Contains("replays"));
            Assert.AreEqual(true, anagrams.Contains("sparely"));
            Assert.AreEqual(true, anagrams.Contains("parsley"));
        }