Пример #1
0
        public void IsSpellingCorrect_Returns_False_For_Invalid_Word()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();

            // Act
            var IsSpellingCorrect = spellChecker.IsSpellingCorrect("hello");

            // Assert
            Assert.IsFalse(IsSpellingCorrect);
        }
Пример #2
0
        public void IsSpellingCorrect_Returns_True_For_Valid_Word()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();

            spellChecker.AddWord("Hello");

            // Act
            var IsSpellingCorrect = spellChecker.IsSpellingCorrect("hello");

            // Assert
            Assert.IsTrue(IsSpellingCorrect);
        }
Пример #3
0
        public void GetSuggestedWords_Returns_Candidate_With_EditDistance_2()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();
            var dictionary   = new List <string> {
                "moon", "soon", "mono", "windows"
            };

            spellChecker.Train(dictionary);

            // Act
            var suggestion = spellChecker.GetSuggestedWords("windwo", 2);

            // Assert
            Assert.AreEqual(1, suggestion.Count);
            Assert.AreEqual("windows", suggestion[0].Word);
        }
Пример #4
0
        public void GetSuggestedWords_Returns_Candidate_With_Sorted_By_EditDistance_Then_by_Word()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();
            var dictionary   = new List <string> {
                "moon", "son", "mono", "money"
            };

            spellChecker.Train(dictionary);

            // Act
            var suggestion = spellChecker.GetSuggestedWords("mon", 2);

            // Assert
            Assert.AreEqual(4, suggestion.Count);
            Assert.AreEqual(1, suggestion[0].EditDistance);
            Assert.AreEqual("mono", suggestion[0].Word);
            Assert.AreEqual(1, suggestion[1].EditDistance);
            Assert.AreEqual("moon", suggestion[1].Word);
            Assert.AreEqual(1, suggestion[2].EditDistance);
            Assert.AreEqual("son", suggestion[2].Word);
            Assert.AreEqual(2, suggestion[3].EditDistance);
            Assert.AreEqual("money", suggestion[3].Word);
        }