コード例 #1
0
ファイル: SpellCheckerTest.cs プロジェクト: Musfiqur01/MSpell
        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
ファイル: SpellCheckerTest.cs プロジェクト: Musfiqur01/MSpell
        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
ファイル: SpellCheckerTest.cs プロジェクト: Musfiqur01/MSpell
        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
ファイル: SpellCheckerTest.cs プロジェクト: Musfiqur01/MSpell
        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);
        }