Пример #1
0
        public void GetListOfClosestWordsFuncTest()
        {
            // arrange
            ILevenshteinDistance levDist = new WagnerFischer();
            List<string> origWords = new List<string>()
            {
                "First",
                "Second",
                "Third",
                "Fourth",
                "Fifth",
                "Sixth"
            };
            MockDictionaryFileFiller filler = new MockDictionaryFileFiller(origWords);
            WordsDictionary dic = new WordsDictionary(levDist, filler);
            List<string> resWords = new List<string>()
            {
                "First",
                "Fifth"
            };
            // act
            List<string> res = dic.GetClosestWords("Funci");

            // assert
            Assert.IsTrue(Enumerable.SequenceEqual(resWords, res));
        }
Пример #2
0
        public void GetListOfClosestWordsCountTest()
        {
            // arrange
            MockLevenshteinDictionary levDist = new MockLevenshteinDictionary();
            List<string> origWords = new List<string>()
            {
                "First",
                "Second",
                "Third",
                "Fourth",
                "Fifth",
                "Sixth"
            };
            MockDictionaryFileFiller filler = new MockDictionaryFileFiller(origWords);
            WordsDictionary dic = new WordsDictionary(levDist, filler);

            // act
            List<string> res = dic.GetClosestWords("Seventh");

            // assert
            Assert.AreEqual(origWords.Count, levDist.CalcLevenshteinDistanceEnters);
        }